Solved

How to change onclick destination url in parent frame.

Posted on 2008-10-16
4
1,262 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
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now