Web Analytics Made Easy -
StatCounter Need help with a making js read url values - CodingForum


No announcement yet.

Need help with a making js read url values

  • Filter
  • Time
  • Show
Clear All
new posts

  • Need help with a making js read url values

    I hope I can explain this is a simple matter.

    The code below is what is inside "code.js"
    I activate it using this in my html.
    <script type="text/javascript" language="JavaScript"src="code.js""></script>

    Now what I want to do is be able to change 3 values with the url.


    So it would be like..
    <script type="text/javascript" language="JavaScript"src="code.js?channel=Channel_Name&width=520&height=500""></script>

    Now channel name would be this line in the code.js
    document.write("<param name=channel value=CHANNEL_NAME>")
    I want whatever is in the url to change the value of the name like

    the same goes for the width and height settings

    height=\"360\" width=\"600\">")

    to be able to change these thru the url as well so it would be like.

    +height+ & +width+ etc..

    You get the idea? I've tried many things but haven’t been able to figure it out yet. Maybe someone can help me please?

    document.write("<applet archive=\"http://backpack.webmaster.com/backpack/cr.zip\" codebase=\"http://backpack.webmaster.com/backpack/\" name=cr code=\"ConferenceRoom.class\" height=\"360\" width=\"600\">")
    document.write("<param name=channel value=NEEDSTHISCHANGED>")
    document.write("<param name=showbuttonpanel value=false>")
    document.write("<param name=bg value=FFFFFF>")
    document.write("<param name=fg value=000000>")
    document.write("<param name=roomswidth value=0>")
    document.write("<param name=lurk value=false>")
    document.write("<param name=simple value=false>")
    document.write("<param name=restricted value=false>")
    document.write("<param name=showjoins value=true>")
    document.write("<param name=showserverwindow value=true>")
    document.write("<param name=nicklock value=false>")
    document.write("<param name=playsounds value=true>")
    document.write("<param name=onlyshowchat value=false>")
    document.write("<param name=showcolorpanel value=false>")
    document.write("<param name=floatnewwindows value=false>")
    document.write("<param name=timestamp value=false>")
    document.write("<param name=listtime value=0>")
    document.write("<param name=guicolors1 value=\" youColor=000000;operColor=FF0000;voicecolor=006600;userscolor=000099\">")
    document.write("<param name=guicolors2 value=\" inputcolor=FFFFFF;inputtextColor=000099;sessioncolor=FFFFFF;systemcolor=0000FF \">")
    document.write("<param name=guicolors3 value=\" titleColor=FFFFFF;titletextColor=000099;sessiontextColor=000000\">")
    document.write("<param name=guicolors4 value=\" joinColor=009900;partColor=009900;talkcolor=000099\">")
    Last edited by b1ing; Feb 26, 2004, 09:39 PM.

  • #2
    If I understood you correctly...

    Why not put the document.write statements inside a function that accepts parameters for channel name, width and height?
    function displayApplet(chName, w, h){
      document.write('<applet width="'+w+' height="'+h+'" codebase=...');
      document.write('<param name="channel" value="'+chName+'">');
    Then call displayApplet where you want the applet displayed.

    <script type="text/javascript">
    displayApplet('This is the channel name', 520, 500);
    Last edited by glenngv; Feb 26, 2004, 09:57 PM.
    vBulletin Mods That Rock!


    • #3
      Hi because i need to work like this
      <script type="text/javascript" language="JavaScript"src="code.js?channel=Channel_Name&width=520&height=500""></script>

      This way other users can modify it can put it on there websites. the code.js will be in my domain, so the user would modify the name, width, height etc to fit there own website.


      • #4
        Using the code I posted, the user can modify the name, width, height.

        The user just needs to include your script like this:

        <script type="text/javascript" language="JavaScript" src="code.js"></script>

        Then somewhere in the body, call the displayApplet() function passing the name, width and height.

        <script type="text/javascript">
        displayApplet('This is the channel name', 520, 500);

        Using your way won't work as javascript can't read the url paramaters in the src attribute.
        vBulletin Mods That Rock!


        • #5
          Hi thank you, I will use your method.