SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Enthusiast Apatgee's Avatar
    Join Date
    Nov 2003
    Location
    UK
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Placing Javascript "off page" or seperate .js file

    Now optimising your web pages for the high search engine ranking they deserve requires placing the javascript in a seperate place on the site ie cgi-bin.
    Why because some daft robots are reading it!
    Any way explain to me how this is done ??
    Yes I create a seperate file and save it in the afore mentioned bin.
    But how do I call it up from the page.???
    Any help appreciated.
    [SIZE=2]Apatgee[FONT=Arial]

    Every little helps
    Beyonder Search Engine Optimisation

  2. #2
    SitePoint Zealot
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    147
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <script type="text/javascript" src="your_file_goes_here.js"></script>
    this piece of code loads your javascript-file. after that you can eventually open some more script tags for example to call functions defined in the file...

  3. #3
    SitePoint Enthusiast Apatgee's Avatar
    Join Date
    Nov 2003
    Location
    UK
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks PC Freak,that will save me time and wonga
    [SIZE=2]Apatgee[FONT=Arial]

    Every little helps
    Beyonder Search Engine Optimisation

  4. #4
    SitePoint Addict
    Join Date
    Mar 2004
    Location
    Europe
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It also makes cross-site scripting easy peasy. It's like css - you change the .js file and anywhere you have the script on the site it will change.

    Aside from bots not seeing it I think you will find that is a most elegant solution. HMTL looks neater too!

  5. #5
    SitePoint Member
    Join Date
    Apr 2004
    Location
    tr
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried to put these select menu codes into a js file and call it from main html page but it didn't work.

    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_jumpMenu(targ,selObj,restore){ //v3.0
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
    }
    //-->
    </script>

    <select name="menu1" onChange="MM_jumpMenu('self',this,0)" style="background:afbacf;color:#000040">
    <option value="#" selected> &gt; menu &lt;</option>
    <option value="alexia_anl1.html">Part 1</option>
    <option value="alexia_anl2.html">Part 2</option>
    </select>

    i made one but in that there is input button which I have to click to go to my selection but in this it goes directly to selected item without waiting. and I couldn't write this into js files.

    can anybody help me?

  6. #6
    SitePoint Evangelist
    Join Date
    Sep 2003
    Location
    San Diego, CA
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In a Js File, you don't need the <script> tags

  7. #7
    SitePoint Member
    Join Date
    Apr 2004
    Location
    tr
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kgh
    In a Js File, you don't need the <script> tags
    yeah I know. i made one select menu with js files and it worked but in that one I used input code which I have to click when I want to go my selection.
    but in the above code I don't need to put a go message and it directly go to the link I wanted after I made my choose from list. but although all my tries it didn't work in js files

    ---------------------->
    function go() {
    if (document.selecter.select1.options[document.selecter.select1.selectedIndex].value != "none") {
    location = document.selecter.select1.options[document.selecter.select1.selectedIndex].value
    }
    }
    ********
    document.write('<form name="selecter"><select name="select1" size="1">');
    document.write('<option value="none">Sešiminizi yapınız');
    document.write('<option value="none">_______________');
    document.write('<option value="sd2_1.html">Part 1');
    document.write('<option value="sd2_2.html">Part 2');
    document.write('</select>');
    document.write('<INPUT TYPE="button" VALUE="Go" onclick="go()">');
    document.write('</form>');
    ---------------------->
    this one worked. ok

    but not this one which I want
    ---------------------->
    function MM_jumpMenu(targ,selObj,restore){
    eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
    if (restore) selObj.selectedIndex=0;
    }
    *******
    document.write('<select name="menu1" onChange="MM_jumpMenu('self',this,0)">');
    document.write('<option value="#" selected> &gt; menu &lt;');
    document.write('<option value="alexia_anl1.html">Part 1');
    document.write('<option value="alexia_anl2.html">Part 2');
    document.write('</select>');
    ---------------------->
    where am I doing wrong?

  8. #8
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Might be unrelated, but <option> requires an </option> closing tag.
    ::: certified wild guess :::

  9. #9
    SitePoint Member
    Join Date
    Apr 2004
    Location
    tr
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by adios
    Might be unrelated, but <option> requires an </option> closing tag.
    no it's not needed to use </option> to close <option> it works like that too.

    anyway I made it by myself.

    thank you.

  10. #10
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes it is needed. Lots of things 'work' without being correct.

    http://www.w3.org/TR/REC-html40/inte...ml#edef-OPTION
    ::: certified wild guess :::


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •