Solved

change onclick event of opener?

Posted on 2006-07-12
9
587 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

758 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

23 Experts available now in Live!

Get 1:1 Help Now