lovekit Posted October 31, 2009 Share Posted October 31, 2009 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 More sharing options...
thescientist Posted October 31, 2009 Share Posted October 31, 2009 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 More sharing options...
Redroest Posted October 31, 2009 Share Posted October 31, 2009 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 More sharing options...
lovekit Posted November 4, 2009 Author Share Posted November 4, 2009 Thanks for answerbut can't Add new acript anyway?I meant without editing html file (in sample is index.php) Link to comment Share on other sites More sharing options...
Ingolme Posted November 4, 2009 Share Posted November 4, 2009 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 More sharing options...
jeffman Posted November 4, 2009 Share Posted November 4, 2009 Without making changes to your document, no. It cannot be done. Your document has to be written so that it is prepared to examine the URI. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.