0

I am trying to make a bookmarklet, that navigates to http://projects.csail.mit.edu/church/wiki/ChurchServ and then inserts some code into the input-box on this site.

I was trying this:

<a href="javascript:
var w=window.open('http://projects.csail.mit.edu/church/wiki/ChurchServ','_blank');
w.onload=function(){w.getElementsByClassName('scheme-comment')[0].textContent='my code...';};
">Klick me!</a>

It is loading the page but does not modify it. Whats going wrong?

Max Tet
  • 735
  • 1
  • 8
  • 16

1 Answers1

0

You can not open a window of different domain and modify its content by JS because of same origin policy.

See the last question on this FAQ

Also note w is a window object. window object doesn't have getElementsByClassName method. That method belongs to document. But you can not access the document object due to same-origin-policy

Shiplu Mokaddim
  • 56,364
  • 17
  • 141
  • 187