Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Link to Iframe from a non-frame page?

Status
Not open for further replies.

dodge20

MIS
Joined
Jan 15, 2003
Messages
1,048
Location
US
Is this possible? I am creating a website that uses a template for the majority of the pages, but for some pages, it pulls external pages using iframe. My problem arises when I try to link from a non-frame page to the framed page and still pull the correct information into the iframe. Lets call my frameset page - 'frameset.html' with the iframe named 'iframe'.

I have a menu with links to both the non-frame and framed pages. If I am on the frameset.html this code works fine

Code:
mm_menu_0207134928_0_3.addMenuItem("Overview","window.open(' [URL unfurl="true"]http://www.external1.com/',[/URL] 'iframe');");

I can then link to a non framed page by using this -

Code:
mm_menu_0207134928_0.addMenuItem(mm_menu_0207134928_0_1,"window.open('default.asp', '_top');")

My problem arises, when I try to navigate back to the iframe. I somehow need to specify the frameset.html and iframe in order to maintain the appearence and not open it in a new window. Right now when I link back to iframe, it try to open that page in a new window.
Sorry if this is confusing.

Dodge20
 
I don't want it to open in a new window. I know frames are bad, but I don't know of another solution to pull in another website into yours without using iframes.

Dodge20
 
That is the only way I know how to make the iframe link work correctly. So is what I am asking possible to do?

Dodge20
 
when you create a link, you can provide a target.

Code:
<a href="mylink.html" target="_blank">blah</a>

_blank is a blank page.

Code:
<a href="mylink.html" target="myIFrame">blah</a>

myIFrame is the iframe's name/id.



*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
Let me try to explain this again. This time without framesets to avoid confusion.

I have a menu that contains several popup menus.

My page default.asp is a regular page that contains no frames.
I created a page from my template called iframe.html. In the body it contains this code. And that is it.

Code:
<iframe name="iframe" src ="" width="100%" scrolling="auto"></iframe>

Then in my dropdown menu code I have
Code:
mm_menu_0207134928_0_3.addMenuItem("Overview","window.open(' [URL unfurl="true"]http://www.external1.com/',[/URL] 'iframe');");
So this will open external1.com in my iframe when coming from my iframe.html page - which is what it is supposed to do.

Then when I click on the home menu link
Code:
mm_menu_0207134928_0.addMenuItem(mm_menu_0207134928_0_1,"window.open('default.asp', '_top');")
I use the
Code:
mm_menu_0207134928_0.addMenuItem(mm_menu_0207134928_0_1,"location='default.asp'");

But now when I click back on the link that is supposed to get me to the iframe.html with the iframe located in the body. It tries to open a new window.

I need it to open the iframe.html page and the link to the external site in the iframe.

Dodge20
 
Sorry ignore the

Code:
mm_menu_0207134928_0.addMenuItem(mm_menu_0207134928_0_1,"window.open('default.asp', '_top');")

in my last post.

Dodge20
 
The problem is, i don't have a way to link back to the iframe.html page and keep the external1.com link in the popup menu.

Dodge20
 
Ok, I gave up on that approach, and just created a new page for each page containing an iframe. So for example I have default.asp - no iframe and overview.asp - with iframe.

How do I target the iframe without using window.open?

Code:
mm_menu_0207134928_0_3.addMenuItem("Overview","window.open('overview.asp', 'iframe');");

Dodge20
 
impossible to tell without seeing the code inside the addMenuItem function.



*cLFlaVA
----------------------------
spinning-dollar-sign.gif
headbang.gif
spinning-dollar-sign.gif

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Code:
function addMenuItem(label, action) {
	this.items[this.items.length] = label;
	this.actions[this.actions.length] = action;
}

this.addMenuItem = addMenuItem;

Dodge20
 
What about replacing window.open with location.replace? Or if there is a better solution I will be all for it. This method takes away the back option in the browser obviously.

I tried window.navigate and window.location, but they don't seem to work in firefox. Is this my best option?

Dodge20
 
I have to agree with cLFlaVA on this one... you appear to have an overly complex solution for no technical reason. It's probably a good idea to take a step back and plan a new way forward. You don't need javascript to do what you asked.

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top