I want to achieve something like this:
location.replace("some url");
alert("hello");
I know this won't work but it runs before the next page is loaded and onload doesn't seem to work either is there a way to achieve this?
So, I finally came to the conclusion that, it is not possible and thanks to @Terry for helping me understand why ( it is a security issue ).
But I got an alternative method for what I want to do. I will copy the website I wanted to run script on and I will host it in another site and I will change the address bar url to what I want by including a script to the site I cloned, hopefully no one notice.