Solved

change onclick event of opener?

Posted on 2006-07-12
9
590 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
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 …
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…

895 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

11 Experts available now in Live!

Get 1:1 Help Now