Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 648
  • Last Modified:

change onclick event of opener?

Is it posible to change the onclick event of a link on the opener page?
0
Brian Coughter
Asked:
Brian Coughter
2 Solutions
 
enachemcCommented:
Short answer: yes. You have access to all opener's page DOM.
0
 
Brian CoughterOwnerAuthor Commented:
So how can I write it?
0
 
0h4crying0utloudCommented:

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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
0h4crying0utloudCommented:

as long as you are in the same domain (pop-up and opener), there should not be a problem...
0
 
Brian CoughterOwnerAuthor Commented:
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
 
sam85281Commented:
<script>
var myWin = null;
function clickIt () {
if (myWin && !myWin.closed) {
alert("Window is already open");
} else {
myWin = window.open('window.html', '');
}
}
</script>

-Sam
0
 
0h4crying0utloudCommented:

"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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now