IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> How To Command Java Script With Url, to type script in address bar after URL to command it to run function
lovekit
post Oct 31 2009, 11:37 AM
Post #1


Newbie
*

Group: Members
Posts: 12
Joined: 10-October 09
Member No.: 34,409



For a sample :
I have my website, which the URL is http://www.mytestsite.com/ < just example not my real Site URL
and 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 answers
If you want more information about my questions Please Reply to ask for it (IMG:style_emoticons/default/smile.gif)


PS.
I'm not good in using English Language.
if I use unproper word, Please forgive me

This post has been edited by lovekit: Oct 31 2009, 11:39 AM
Go to the top of the page
 
+Quote Post
thescientist
post Oct 31 2009, 11:42 AM
Post #2


Likes gettin' it on!
***

Group: Members
Posts: 643
Joined: 24-May 08
From: Rhode Island, USA
Member No.: 22,266
Languages: (X)HTML, CSS, Javascript, PHP/MySQL, XML, Java (still gettin a grip on those last couple)



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.
Go to the top of the page
 
+Quote Post
Redroest
post Oct 31 2009, 06:56 PM
Post #3


Newbie
*

Group: Members
Posts: 48
Joined: 23-October 09
Member No.: 34,709



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

CODE
<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=Redroest
You 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:

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


This post has been edited by Redroest: Oct 31 2009, 06:59 PM
Go to the top of the page
 
+Quote Post
lovekit
post Nov 4 2009, 03:12 PM
Post #4


Newbie
*

Group: Members
Posts: 12
Joined: 10-October 09
Member No.: 34,409



Thanks for answer
but can't Add new acript anyway?
I meant without editing html file (in sample is index.php)
Go to the top of the page
 
+Quote Post
Ingolme
post Nov 4 2009, 03:18 PM
Post #5


Duotone Fox
*****

Group: Members
Posts: 3,585
Joined: 6-November 07
Member No.: 18,212
Languages: (X)HTML, CSS, Javascript, PHP, SQL, XML [DOM].



QUOTE (lovekit @ Nov 4 2009, 03:12 PM) *
Thanks for answer
but 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.
Go to the top of the page
 
+Quote Post
Deirdre's Dad
post Nov 4 2009, 03:34 PM
Post #6


Devoted Member
*****

Group: Members
Posts: 3,319
Joined: 16-January 08
Member No.: 19,529



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.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 23rd November 2009 - 04:28 AM