Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to change onclick destination url in parent frame.

Posted on 2008-10-16
4
Medium Priority
?
1,278 Views
Last Modified: 2009-01-28
Okay i have Main Frame which has an iframe inside it.

in main frame there is image

<td rowspan="3" valign="top"><a href="#"><img src="template_05.gif" width="172" height="45" border="0" onclick="openw('https://www,google.com',0,0,0,0,0,1,1,900,900,200,1,1);" value="openw"/></a></td>

now www.google.com i need to change to www.yahoo.com

i have the code which does it but only in iframe .It doesn't change the main frame img.How can i override it?


<script language="JavaScript">
// THIS IS THE CODE TO CHANGE URL FOR THE CURRENT FRAME
function rpl (){
        var imgs = document.getElementsByTagName("img");
        for(var i = 0; i < imgs.length; i++) {
                var img = imgs[i];
                if(img.getAttribute("value") == "openw") {
                        img.setAttribute("onclick", imgs[i].getAttribute("onclick").replace("https://www.google.com", "http://www.yahoo.com"));
                }
        }
        }
        window.onload=rpl;
</script>

Open in new window

0
Comment
Question by:olivest
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 

Accepted Solution

by:
olivest earned 0 total points
ID: 22732706
Just realised need to add little word "parent" in front of document.getElementsByTagName("img");
0
 
LVL 8

Expert Comment

by:MatthiasVance
ID: 22732739
I was *just* about to post that indeed. Good luck with it!

Kind regards,

Matthias Vance
0
 
LVL 19

Expert Comment

by:NerdsOfTech
ID: 22805504
opener.[object] to reference the opener frame (popup)
OR
parent.[object] to reference the parent frame
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question