Nov 22, 2009

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

free web hosting
Open Discussion > MODERATED AREA > Computers > Programming Languages > HTML, XML etc..

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

BCD
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.

Comment/Reply (w/o sign-up)

jlhaslip
target=_blank

Comment/Reply (w/o sign-up)

BCD
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:

CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta 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:

CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta 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.

 

 

 


Comment/Reply (w/o sign-up)

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

CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta 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>


Comment/Reply (w/o sign-up)

BCD
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.

Comment/Reply (w/o sign-up)

galexcd
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
CODE
<? ob_start() ?>


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

Comment/Reply (w/o sign-up)

BCD
Hey, thats exactly what I needed. The PHP method works charmingly. Thanks a ton galexcd, you saved my day. Thanks once again.  smile.gif

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords :

  1. Xhtml Strict Links Tip
    A problem might accure (5)
  2. Links Help Please
    :) (10)
    Okay i have links that work at my house but not at school where i am trying to edit the HTML, the
    site is www.gaming-alliance.net, the links arent set anywhere but it should still send me to a blank
    page if the link i sent it to does not exist. Could someone please check it out and see if its
    working on a different computer? because it works on mine at home heres the code... Gaming
    Alliance | Next Generation Of Gamers Today Thanks.....
  3. Image Links
    (5)
    Ok...another question...may sound stupid, but we're all stupid...how'd I be able to create
    an image link. Uh...let me rephrase this: If I were to create an "Enter" image and wanted people to
    click the image to enter to a certain page, how would I do it without some sort of the famous "Blue
    Line" around it? Any help would be greatly appreciated... /unsure.gif"
    style="vertical-align:middle" emoid=":unsure:" border="0" alt="unsure.gif" />....
  4. Keyboard Shortcut For Links In Html?
    (8)
    Is there a way to make use of the keyboard when togging html links? I'm doing a project and it
    would be nice if the user won't be too mouse-dependent. He will have the option of using the
    keyboard as well. I'm thinking if the user does a particular keypress (CTRL + LETTER maybe? )
    the link will be "clicked". This is probably a stupid question but if anyone knows a way it would
    be so fantastic! /cool.gif" style="vertical-align:middle" emoid="B)" border="0" alt="cool.gif" />
    Thanks.....
  5. Dynamic Links
    (3)
    his may be a CSS question, but it's the XHTML not validating that's giving me a problem.
    I'm working with the most out-dated shopping cart software (Click Cart Pro) ever and I'm
    trying to get it to validate XHTML 1.0 Transitional. All the XHTML I've supplied is good and
    validates fine, but where I'm falling short at the moment is with the linking. ClickCart Pro -
    by default - spits out HTML from 1996, and the links are supplied with ampersands - not the XHTML
    character entity "&". Par l'exemple: Code: CODE I'm wondering i....
  6. Trouble With Links On A List
    i want to display it inline (7)
    I have a menu that i want to display inline, in the same row, something like this: CODE
    ul{float:left;width:100%;padding:0;margin:0;}
    a{float:left;text-decoration:none;color:white;background-color:red; padding:5px 10px;} a:hover
    {background-color:blue} li {display:inline} The only problem is that i want a custom img for
    showing as CODE list-style: url(img/bullet.gif) But seems that display:inline makes my
    bullet go away... could some one point me in the right direction? Thanks in advance.......
  7. Update Navigation Links?
    (2)
    One of the requirements for the site Im working on right now is to be able to update navigation
    links easily. Its easy to do with frames, which I want to avoid. If I have 8 different pages, and
    add another page or anything, I dont want to have to open 8 pages and make the change to all of
    them. Is there another way, like having some kind of external style sheet, and bieng able to update
    that and have it carry over to all the other pages? As far as I understand, you can only have CSS
    code in a external stylesheet, and all the link infomation is in the actual page itself.....
  8. Dropdown Menus Links
    IDK how to make them link (3)
    Ok its a big problem to me, i need to make my drop down menus options link to a web page. I know i
    can do it with a button, and i can get that to work but i need/want to have it link as soon as the
    option is selected........How do i do that?....
  9. Need To Learn Xml Quick
    links or info on xml (8)
    I need to learn xml and would like links or anything on the subject. I've looked at some code
    and i still don't see the point to it at all. round ....
  10. Frames And Links
    (3)
    I don't often use frames and I am having a problem linking from page to page. I am using php.
    I have a link with goes: result 1 In results.php I create my frames and use 'if' queries
    to select a frameset depending on the variable passed in the link, so it goes: if ($_GET ) { else
    ...and so on. My problem is this - when I use target="result1", a new window opens and loads the
    page the way I want it, but I don't want a new window to open. If i put target="_self", then
    the page loads in the same window, but the page 'results.php' appears....

    1. Looking for Make, Links, In, Inframe, Open, In, New, Window

Searching Video's for Make, Links, In, Inframe, Open, In, New, Window
See Also,
advertisement


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

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com