Solved

change onclick event of opener?

Posted on 2006-07-12
9
615 Views
Last Modified: 2007-12-19
Is it posible to change the onclick event of a link on the opener page?
0
Comment
Question by:Brian Coughter
[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
9 Comments
 
LVL 12

Accepted Solution

by:
enachemc earned 250 total points
ID: 17091920
Short answer: yes. You have access to all opener's page DOM.
0
 

Author Comment

by:Brian Coughter
ID: 17091929
So how can I write it?
0
 
LVL 10

Expert Comment

by:0h4crying0utloud
ID: 17092040

somn like this:

<script>
function testf2() {
  alert("this is test ");
}

alert( "test: " + window.opener.document.getElementById('testLink').onclick );
                  window.opener.document.getElementById('testLink').onclick = testf2;
alert( "test: " + window.opener.document.getElementById('testLink').onclick );
</script>
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:0h4crying0utloud
ID: 17092047

as long as you are in the same domain (pop-up and opener), there should not be a problem...
0
 

Author Comment

by:Brian Coughter
ID: 17092170
I put this on my iframe source to a button that contains the iframe tag and I get an error

<body onLoad="window.opener.document.getElementById('backButton').onclick = 'google.com'">

ERROR: window.opener.document is null or not an object
0
 
LVL 16

Expert Comment

by:sam85281
ID: 17092305
<script>
var myWin = null;
function clickIt () {
if (myWin && !myWin.closed) {
alert("Window is already open");
} else {
myWin = window.open('window.html', '');
}
}
</script>

-Sam
0
 
LVL 10

Assisted Solution

by:0h4crying0utloud
0h4crying0utloud earned 250 total points
ID: 17092325

"opener" is for pop-ups.. not iframes...

this should work in an iframe:

<script>
function testf2() {
  alert("this is test ");
}

alert( "test: " + parent.document.getElementById('testLink').onclick );
                  parent.document.getElementById('testLink').onclick = testf2;
alert( "test: " + parent.document.getElementById('testLink').onclick );
</script>
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

707 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