Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: checking url

  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    checking url

    heya, Ok, im trying to check the url using java script

    essentially this is what i would like to do

    if url1 = current_url {
    import script 1
    } else
    if url1 = current_url {
    import script 2
    } else
    if url1 = current_url {
    import script 3
    }

    any help, suggestions would be ideal, thankyou

    i should also point out that im not the most compitant programmer, nor do i know java script ><

  • #2
    Senior Coder chump2877's Avatar
    Join Date
    Dec 2004
    Location
    the U.S. of freakin' A.
    Posts
    2,769
    Thanks
    19
    Thanked 155 Times in 146 Posts
    I think you want something like this:

    Code:
    <script type="text/javascript">
    
    if (url1 == window.location.href)
        addJavascript(scriptName1);
    else if (url2 == window.location.href) 
        addJavascript(scriptName2);
    else if (url3 == window.location.href) 
        addJavascript(scriptName3);
    
    
    function addJavascript(jsname) 
    {
        var th = document.getElementsByTagName('head')[0];
        var s = document.createElement('script');
        s.setAttribute('type','text/javascript');
        s.setAttribute('src',jsname);
        th.appendChild(s);
    }
    
    </script>
    Regards, R.J.

    ---------------------------------------------------------

    Help spread the word! Like my YouTube-to-Mp3 Conversion Script on Facebook !! :)
    [Related videos and tutorials are also available at my YouTube channel and on Dailymotion]
    Get free updates about new software version releases, features, and bug fixes!

  • #3
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks mate, appreciated a littel fiddling around and its all working


  •  

    Posting Permissions

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