Jump to content

How To Command Java Script With Url


lovekit

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

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>

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...