www.webdeveloper.com
Results 1 to 3 of 3

Thread: If URL contains this show this logo in the container div

  1. #1
    Join Date
    Apr 2013
    Posts
    2

    If URL contains this show this logo in the container div

    I have a script that's firing but the logo isn't changing in the div I've declared, complete newbie here.

    <script>
    if(document.URL.indexOf("index.html") >= 0){
    alert('hello');
    $("logocontainer").html("<a href=\"http://www.site.com\" target=\"_blank\"><img src=\"images/logo_tx.png\" border=\"0\" alt=\"Illinois\"></a>");
    }
    if(document.URL.indexOf("bcbstx") >= 0){
    $("logocontainer").html("<a href=\"http://www.site.com\" target=\"_blank\"><img src=\"images/logo_tx.png\" border=\"0\" alt=\"Texas\"></a>");
    }
    if(document.URL.indexOf("bcbsnm") >= 0){
    $("logocontainer").html("<a href=\"http://www.site.com\" target=\"_blank\"><img src=\"images/logo_nm.png\" border=\"0\" alt=\"New Mexico\"></a>");
    }
    if(document.URL.indexOf("bcbsok") >= 0){
    $("logocontainer").html("<a href=\"http://www.site.com\" target=\"_blank\"><img src=\"images/logo_ok.png\" border=\"0\" alt=\"Oklahoma\"></a>");
    }
    </script>

  2. #2
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    Code:
    if(document.URL.match("bcbstx") ){ 
       $("logocontainer img").attr("src", "images/logo_tx.png");
    }

  3. #3
    Join Date
    Apr 2013
    Posts
    2
    Thanks for all that helped, but I found the solution. I forgot to add a "#" in front of the div id.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles