Jump to content

How To Command Java Script With Url


lovekit
 Share

Recommended Posts

For a sample :I have my website, which the URL is http://www.mytestsite.com/ < just example not my real Site URLand in The file "index.php", which contain JavaScript command function such as "onHoverTest()" or "clickTest()"the function : onHoverTest() will run its process, when mouse pointer is hover on Web Object (picture, link, etc)and function : clickTest() will run its process, when user click the Web Object (picture, link, etc)So, this is my questions:1. If some times I want to run one of all functions process at the page start , Without processing condition. - Can I add some command to run script on the address bar after normal URL (Eg. http://www.mytestsite.com/ "add command for runnig script here" ) or anyway?2. If I want to add some JavaScript command(that have not in the "index.php" file) - can I add it using addressbar after URL (Eg. http://www.mytestsite.com/ "add new JavaCript here") or anyway?Thanks you all for answersIf you want more information about my questions Please Reply to ask for it :)PS.I'm not good in using English Language.if I use unproper word, Please forgive me

Edited by lovekit
Link to comment
Share on other sites

if you want something to happen when the page loads, there is a function called onLoad, which you can apply to the <body> tag of an HTML document.

Link to comment
Share on other sites

You can use somthing like this to get values from an url:

<script type=javascript>function GetURLvalues(key){  var regexS = key+"=([^]*)";  var results = window.location.match(regexS);  if( results == null )	{	return "";	}  else	{	return results[1];	}}</script>

Lets say that your URL is: www.website.com/index.php?member=RedroestYou can call the function like this: GetURLvalues("member");This will return the value of "member" (in this case Redroest)When this works, you can use this function to activate a java script:

<script type=javascript>if(GetURLvalues("member") == Redroest){  alert("javascript activated with help of the URL that called this page");}</script>

Edited by Redroest
Link to comment
Share on other sites

Thanks for answerbut can't Add new acript anyway?I meant without editing html file (in sample is index.php)
No, you can't use a link to make Javascript run on another page. It could be a tricky way to give people the wrong impression of other websites.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...