Detect current page using JS

Ask a Question related to Macromedia Dynamic HTML, Design and Development.

  1. #1

    Default Detect current page using JS

    Hi all, I would've figured this out myself, but I'm stumped on this.... why
    doesnt this work?

    <script type="text/javascript">
    document.write("[BULLET]");
    document.write(" [LI]<a href='index.html' " +
    if(window.location.href.match("index.html")) { document.write(" class='x'"); }
    + ">link</a></li>");
    document.write(" [LI]<a href='links.htm'>link</a></li>");
    document.write(" [LI]<a href='contact.htm'>link</a></li>");
    document.write("[/BULLET]");
    </script>

    mzanime.com Guest

  2. Similar Questions and Discussions

    1. Detect bottom of page and swap image
      I want to detect when the user has scrolled to the bottom of the page and then swap a 'down' arrow graphic for an 'up' arrow graphic that links to...
    2. Detect leaving page
      Looking for a method to detect when the user presses the "Back" button and also Alt+> Thanks for any insight! Kevin
    3. trying to detect mousemovement to move to next page,like a screensaver
      Hi, I'm a beginning flash user. First time poster. I found this thread. It is very close to the challenge I am having with my project. I am having...
    4. detect change of remote page
      hi everyone, i have some links on my site, i need to be absolutely sure that the html has not been modified, even one character. i would rather...
    5. redirect to another page based on text in the URL of the current page
      Hi JPElectron, You were looking good until you got to the code. You're trying to use client-side code for your redirects, when you should be...
  3. #2

    Default Re: Detect current page using JS

    please post a URL link to your example page you are working with. IT is more than just javascript by itself, it needs to show html source and see how those two work together.
    Deaf Web Designer Guest

  4. #3

    Default Re: Detect current page using JS

    I happen to notice two different html extensions as in ".html" and ".htm" without letter of a 'l'.
    Deaf Web Designer Guest

  5. #4

    Default Re: Detect current page using JS

    Here's the code. For some reason, it doesn't even render anything on screen! I
    really hope there are a few javascript experts in the house.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <style type="text/css">
    .x { font-weight:bold; }
    </style>
    </head>

    <body>

    <div id="leftnav">

    <script type="text/javascript">
    document.write("[BULLET]");
    document.write(" [LI]<a href='index.html' " +
    if(window.location.href.match("index.html")) { document.write(" class='x'"); }
    + ">link</a></li>");
    document.write(" [LI]<a href='links.htm'>link</a></li>");
    document.write(" [LI]<a href='contact.htm'>link</a></li>");
    document.write("[/BULLET]");
    </script>

    </div>

    </body>
    </html>


    mzanime.com Guest

  6. #5

    Default Re: Detect current page using JS

    Here's the code. For some reason, it doesn't even render anything on screen! I
    really hope there are a few javascript experts in the house.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <style type="text/css">
    .x { font-weight:bold; }
    </style>
    </head>

    <body>

    <div id="leftnav">

    <script type="text/javascript">
    document.write("[BULLET]");
    document.write(" [LI]<a href='index.html' " +
    if(window.location.href.match("index.html")) { document.write(" class='x'"); }
    + ">link</a></li>");
    document.write(" [LI]<a href='links.htm'>link</a></li>");
    document.write(" [LI]<a href='contact.htm'>link</a></li>");
    document.write("[/BULLET]");
    </script>

    </div>

    </body>
    </html>


    mzanime.com Guest

  7. #6

    Default Re: Detect current page using JS

    No, its pobably not a good idea to do so, but in meantime I'm working locally
    and I've got no IIS, or PHP engine installed on my notebook, so I'm going to
    work with what I've got. I'll most likely change it to PHP in the future, but
    in the meantime- I'm trying to learn a few things about how javascript works.

    I don't see any reason why this code isn't working.... if no one has any
    ideas, I'm going to go hunting for a Javascript forum.

    mzanime.com Guest

  8. #7

    Default Re: Detect current page using JS

    Michael,

    Ah, I see. If you didn't know about this excellent book about PHP working well
    with Dreamweaver. The book is called "PHP for Dreamweaver 8" who wrote by David
    Powers. I recommend that you consider to buy this book and use it as a
    reference. This book, practically cover fundamentals of how PHP works, even
    covers on how to set up PHP, Apache and few other great topics discussed by
    Author David Powers. I don't think this book won't disappoint you, Michael.

    As for javascript aspect, I like javascript, but with extreme cautious
    approach, though. It is not user friendly and I don't think it is very
    'accessible-friendly' pretty much. That is why I mention that earlier, too.

    Deaf Web Designer Guest

  9. #8

    Default Re: Detect current page using JS

    I've decided to just go with PHP. Sure would be nice to know why this don't work though.... if someone knows, please email me: mike (at) cssdreams (dot) com

    *closes thread*
    mzanime.com Guest

  10. #9

    Default Re: Detect current page using JS

    Michael, let us or me know if you need some help with PHP and all that. Having
    said that, please refer to that book I was talking about. I don't think you
    won't be disappointed, Michael.

    Once you get that book, be sure to refer to the author's website for updated
    information due to a little small hiccups associated with DW8 v. 8.0.2 Updater
    issues. Having said that, so that you know what's up with the latest, updated
    information and additional, new information released from the author through
    his website blog. If for some reason, you could not locate this author's
    website, please do let me know.

    Cheers, DWD

    Deaf Web Designer Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139