Solved

change onclick event of opener?

Posted on 2006-07-12
9
601 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

840 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