Run Javascript Code Inside Another Site

ldg2002

Registered Member
Joined
Jun 5, 2012
Messages
66
Reaction score
6
Hello!
Is there any way to run a javascript inside another site through:
Code:
<script type='text/javascript' src="www.example.com">

    //various operation on the example.com site//

</script>
Thank you!
 
For yourself only yes. For example in opera/firefox you can type

Code:
javascript:{your code}

into the address bar
 
hey, thanks for the reply, but i don't need that.

i have a site where i have
Code:
<script type='text/javascript' src="www.example.com">


    //various operation on the example.com site//


</script>
i need to run code inside this snippet above.
Thank again
 
If you'll explain the purpose of what you're trying to do, it will be easier to answer.
 
look up jsonp and how to deal with it, I suspect it'll come handy ;)
 
If you'll explain the purpose of what you're trying to do, it will be easier to answer.
i'm trying to do that:
when i user visit my site i send a request to another site with:

<script type='text/javascript' src="www.example.com"></script>

it works. Now i need to inject some javascript code, is it possible to do?

Thank you
 
i'm trying to do that:
when i user visit my site i send a request to another site with:

<script type='text/javascript' src="www.example.com"></script>

it works. Now i need to inject some javascript code, is it possible to do?

Thank you

First, if the site is yours, you can put any javascript code inside, and it will be executed by the user. However, javascript is a client side language - means when someone visits your site, the javascript is downloaded to that user's PC and runs locally. Anything that runs locally has no effect on your website, or that another site you speak about.

The only thing that has some effect is AJAX queries - a small part of javascript that makes POST requests to the remote server. But you dont need javascript to make a post request, you can do that directly from PHP.

See, its not that easy to answer without knowing the exact purpose. :-) If you gave details I could just answer just yes or no, and life would be simpler.
 
Thank you Lancis, the big problem is that the site is not mine, and i don't know how to inject javascript code inside.
I'm tryin' to store cookies from site (not mine) and i'm trying to do it in javascript.
i have a working script, but is useless if i can't inject this code into the browser of the users.
Thanks again
 
Thank you Lancis, the big problem is that the site is not mine, and i don't know how to inject javascript code inside.
I'm tryin' to store cookies from site (not mine) and i'm trying to do it in javascript.
i have a working script, but is useless if i can't inject this code into the browser of the users.
Thanks again

Ok, now I understand better I think. You want to force visitors of another site to execute your javascript code?

There are only 2 options I know of:
1. Find an exploit in that site and upload your code (thats illegal, they shot you in Texas for that)
2. Write a useful Firefox plugin and put the code there (thats illegal as well, but the Texans will forgive)
 
Back
Top