0

I would like to host links in my site. That contain onlick event and open in new tab. While opening or after loading, it need to add some code within the loaded page. Is this possible?

And also it need to add onclick event in all links within the loaded page.

<a href="url" onclick="somescript()" target="_blank"> sometext here </a> 

On the page on my site. And JavaScript

<script>
onload = zawgyi ();
function zawgyi() {var fontfamily='Zawgyi-One';
    document.getElementByTagName('body')[0].style.fontFamily=fontfamily;
    //and all the way to p,div,span and so on
};
function somescript(){/*code need to inject the all function including javascript   
    itself  and onclick event on all <a> tag.*/
}:
</script>

I know that I can do this with bookmarklet. But I don't want to click everytime. My objective is to read the zawgyi site by visiting my site and after this the user can go as usual.
I also want to know other ways to fulfill the objective.

MrCode
  • 63,975
  • 10
  • 90
  • 112
Suyu Tu
  • 11
  • 1

2 Answers2

0

Not possible. Use Greasmonkey to avoid having to click a bookmarklet on every visit.

mustafa.0x
  • 1,476
  • 2
  • 17
  • 30
0

Thank about what you are trying to do. Now think about what kind of bad things someone could do if this was possible. That is why it is not possible. The security rule is called "same origin policy".

The way to work around this policy is to create a userscript, extension, or addon.

DG.
  • 3,417
  • 2
  • 23
  • 28