0

Hi I am opening an external website in my pop window. I would like to disable certain links in that popup.

i.e. I am opening http://www.yahoo.com in pop and I want to disable some links in that pop-up so that who ever visit yahoo.com using my website, will not able to click on some links...

Is it possible? any idea?

Developer
  • 25,073
  • 20
  • 81
  • 128
  • Not possible, SOP prevents you from molesting anything from a different domain (http://en.wikipedia.org/wiki/Same_origin_policy) your only option would be to load the page server side, abuse it there then serve it back. – Alex K. Oct 11 '11 at 11:53
  • hmm.. that is what i was thinking :) thanks – Developer Oct 11 '11 at 11:54
  • Sounds like a generel bad idea. But i guess you could load ex. yahoo.com with ajax and then disable links using regular jquery sorting http://stackoverflow.com/questions/303956/jquery-select-a-which-href-contains-some-string – Marco Johannesen Oct 11 '11 at 11:55

2 Answers2

1

It is impossible to run JavaScript on another domain because of the same origin policy. imagine someone opening up your bank account in a new window/frame and altering the links to transfer money to their account. ;)

You can screen scrape the content with your server and redisplay it, but you have to worry about proxying all of the relative links.

epascarello
  • 204,599
  • 20
  • 195
  • 236
0

If you are creating a popup using the standard window.open you can manipulate the DOM of that document. See here for more information on how to do that (towards the bottom of the page). But this is fairly limiting to writing stuff to that page. I suppose you could render the link in an iframe and inject some javascript to manipulate it?

Alex
  • 7,320
  • 1
  • 18
  • 31