-
some code help
hi,
i want to make a script that does the following
some one puts a code in there pages like this
<SCRIPT language="JavaScript" src="http://mysite.com/script.php?id=userid"></SCRIPT>
which would load a java script with that userid inside it
like
win2=window.open ('http://mysite.com/script2.php?id=userid','_blank','top=1,left=1,width=550,height=300,buttons=1,scrollbars=1,location=1,menubar=1,resizable=1,status=1,directories=1,tool bar=1'),win2.blur(),window.focus();
so the php script will echo out the java script and add userid inside it
any one knows how to do this ?
the end reselt the user with this code
<SCRIPT language="JavaScript" src="http://mysite.com/script.php?id=userid"></SCRIPT>
in there page will be converted to
<SCRIPT language="JavaScript" src="my java script inside the script.php with userid inside it"></SCRIPT>
most important that the userid changes for each member
thanks
-
That's kind of an off approach.
What you want to do is define your page with a link that 'onclick' calls your window open script.
you can't do this with javascript alone. You'll need a technology like PHP.
1. Build an HTML page and replace userid with %USERID% - ni our example it will be template.htm
2. Build a PHP page that has available the user's id, in a SESSION variable, or POST - anything you like. If it were stored in a SESSION array it would look like this:
Code:
<?
session_name( 'somename' );
session_start();
$fp = str_replace( '%USERID%', $_SESSION['userid'], implode( '', file( 'template.html' ) );
echo $fp;
?>
this way, the php file reads the unparsed template, replaces %USERID% with the actual user id, and then echoes the result.
HTH
Alex
-
how would the php script know what is userid is ?
this code will change like
<SCRIPT language="JavaScript" src="http://mysite.com/script.php?id=site1"></SCRIPT>
<SCRIPT language="JavaScript" src="http://mysite.com/script.php?id=site2"></SCRIPT>
the php script must think the http://mysite.com/script.php?id=%USERID% and then use it in the templete.html
-
-
any one home ?
is there any other site which has more programers ?
its a simple idear
a code in one page that calls a php script
like
<SCRIPT language="JavaScript" src="http://mysite.com/script.php?id=site2"></SCRIPT>
and this php script in turn gets the userid from the code "id=" and then prints a java code with that same userid
like
win2=window.open ('http://mysite.com/script2.php? id=userid','_blank','top=1,left=1,width=550,height=300'),win2
.blur(),window.focus();
and because the php script was called between <script> and </script> it will be like the original code was
<SCRIPT language="JavaScript">
win2=window.open ('http://mysite.com/script2.php? id=userid','_blank','top=1,left=1,width=550,height=300'),win2
.blur(),window.focus();
</SCRIPT>