Good afternoon,

I was wondering if anyone knows of a way to force a page that always wants to open in a new window to open in an iframe?

I have several links on the same page with an iframe to the side, and i would like it for the pages to open in the iframe without ever leaving the main page, so the user could click a link and the page would appear, and the links are still on the side to be able to click a different one. I have it working right now on most pages, but there are a few pages (which i cannot modify the code) that are opening in new windows, and was curious if there was a way to force it into the frame? Or is there another better method of going about doing this?

Thanks in advance!

Rob

Recommended Answers

All 4 Replies

Hello Rob!

If you would like all links in a given section of your document to open in the iframe (unless specified otherwise through a 'target=...' in the '<a ...>' tag), you can use the <base target='theFrame'>...</base> tags. For example:

iframtest.php

<html><body><center>
<base target="theFrame">

<a href="http://www.facebook.com">Click here for facebook in the iframe</a><br /><br />

<iframe width="500" height="500" src="http://www.google.com" name="theFrame"></iframe>
</center></body></html>

More generally, to ensure that a clicked link opens in an iframe, two things must be set: the name of the iframe and the target of the link. Here is an example:

<html><body><center>

<a href="http://www.facebook.com" target="theFrame">Click here for facebook in the iframe</a><br /><br />

<iframe width="500" height="500" src="http://www.google.com" name="theFrame"></iframe>
</center></body></html>

Note that the targets in the link/base tags and the name of the iframe are the same.

Warm regards and best of luck in your project,
Sam

Good afternoon,

I was wondering if anyone knows of a way to force a page that always wants to open in a new window to open in an iframe?

I have several links on the same page with an iframe to the side, and i would like it for the pages to open in the iframe without ever leaving the main page, so the user could click a link and the page would appear, and the links are still on the side to be able to click a different one. I have it working right now on most pages, but there are a few pages (which i cannot modify the code) that are opening in new windows, and was curious if there was a way to force it into the frame? Or is there another better method of going about doing this?

Thanks in advance!

Rob

i cant open a link--example--i click on a email from jobs.com-it list jobs as a manager-says view discp-i click it and it dont open.-any one know why?

i cant open a link--example--i click on a email from jobs.com-it list jobs as a manager-says view discp-i click it and it dont open.-any one know why?

Dont hijack other peoples threads
start your own

try turn off your pop up blocker(or hold whatever key combination) if the links are configured to open in new windows

Here you using href..
<a href="http://www.facebook.com" target="theFrame">Click here for facebook in the iframe</a><br /><br />
How to the with "button". I mean the click of a should redirect to iframe with a url.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.