Solved

How to change onclick destination url in parent frame.

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

726 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