How get click item from popup window Html Javascript

I want to get click item from popup window. example when i run below code and click google here show a popup window and here show two button 1.Google search 2.I am feeling Lucky.

now i want to get that a user whois button was click ?

`    <html><head></head><script>function popitup(link) { var w = window.open(link.href,
    link.target||"_blank",
    'menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,dependent,width=800,height=620,left=0,top=0'); return w?false:true; // allow the link to work if popup is blocked }</script><body><a href="http://www.google.com" onclick="return popitup(this)">Google</a></body></html>    `

Thanks for help me

I’m sorry, but I really can’t understand what you’re saying here. Could you rephrase it and maybe we can get you some help.

He wants to snoop in on what people do with google and learn which button was clicked, whether it was the search button or the feeling lucky button.

1 Like

I think it will depend on the opened pages same-origin policy

The returned Window reference can be used to access properties and methods of the new window as long as it complies with Same-origin policy security requirements.

.

I can not access the properties of the new secondary window. I always get an error in the javascript console saying "Error: uncaught exception: Permission denied to get property <property_name or method_name>. Why is that?

    • It is because of the cross-domain script security restriction (also referred as the “Same Origin Policy”). A script loaded in a window (or frame) from a distinct origin (domain name) cannot get nor set properties of another window (or frame) or the properties of any of its HTML objects coming from another distinct origin (domain name). Therefore, before executing a script targeting a secondary window, the browser in the main window will verify that the secondary window has the same domain name.

I mean what button click. suppose I open a youtube chanel by popup window now I want get respone if click subscribe button.
plz help

I don’t think you can have access to youtube page.

However, it looks like you can put videos in an iframe into a page, and put a subscribe button into a page.

https://developers.google.com/youtube/youtube_subscribe_button

Dear supose i create popup window from first.html by open.window(“youtube.com/chanel/userchanel”); after opening the
popup window here show chanel subscribe button. now i want to know that user click subscribe button from first.html page. so plz help me

What is the cross-origin policy of the youtube.com domain?

As has been posted, if not clearly enough, is that unless a domain explicitly allows JavaScript on a different domain to interact with it. It can not be done

The JavaScript code from your domain can interact with HTML that is on your domain. You can include content from other domains, but that content is “sandboxed” for security reasons.

3 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.