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
Solved

How to change onclick destination url in parent frame.

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
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…

765 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