Jump to content
xisto Community
BCD

Make Links In Inframe Open In New Window Is it possible?

Recommended Posts

Consider there are several links in an inline frame. How to make those links open in a new window instead of opening in the same frame. I have tried parent, blank targeting but they don't seem to work. Is there any other method? I don't want to change anything inside the iframe.Thanks.

Edited by BCD (see edit history)

Share this post


Link to post
Share on other sites

target=_blank doesn't work. I have even tried "_parent" and "_top". I will put the code here to know what I mean.

index.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://forums.xisto.com/no_longer_exists/ xmlns="http://forums.xisto.com/no_longer_exists/ http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Semi Transparent Player</title></head><body><div><iframe name="FRAME1" target="_blank" src="contact.html" width="730" height="260" frameborder="1" ></iframe><p>INDEX PAGE</p></div></body></html>

contact.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://forums.xisto.com/no_longer_exists/ xmlns="http://forums.xisto.com/no_longer_exists/ http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>ST Player: Contact</title></head><body><div><p><a href="index.html">A Link inside iframe. Make me open in a new window.</a></p></div></body></html>

I want to make the link inside the iframe to open in a new window. I don't want to manually add target=_blank to each of the links. So I want to know if there is some code which can automatically make all the links to open in new window. May be some javascript code does that?

Thanks for the help.
Edited by BCD (see edit history)

Share this post


Link to post
Share on other sites

The target="_blank" should be in the contact.html and not the index.html. This should solve the problem.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://forums.xisto.com/no_longer_exists/ xmlns="http://forums.xisto.com/no_longer_exists/ http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>ST Player: Contact</title></head><body><div><p><a href="index.html" target="_blank">A Link inside iframe. Make me open in a new window.</a></p></div></body></html>

Share this post


Link to post
Share on other sites

Yes kleong that would solve the problem, but in my case there are tons of links inside the iframe and so I cannot manually specify target to each of them. So I was asking if there attribute which we can specify on the iframe itself so that all the links open in new window. I think I should find another solution to my problem now. Thanks for your replies.

Share this post


Link to post
Share on other sites

Find & Replace ftw

Find: <a href=
Replace: <a target="_blank" href=

Most basic text editors should be able to do this.

And if you still don't want to do that I suppose you could let php do the hard work for you. You will need to rename contact to contact.php or add html as one of the file types that php parses in the php configuration settings file.

Put this before any of the code on contact.php

<? ob_start() ?>

And put this after all the code on contact.php
<? $o=str_replace("<a",'<a target="_blank"',ob_get_contents()); ob_end_clean(); echo $o; ?>

Edited by galexcd (see edit history)

Share this post


Link to post
Share on other sites

Hey, thats exactly what I needed. The PHP method works charmingly. Thanks a ton galexcd, you saved my day. Thanks once again.? :lol:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.