New to JavaScript

Discussion in 'JavaScript' started by dp-user-1, Dec 17, 2007.

  1. #1
    Hello all,

    This is my first post in this forum, and I only know a limited amount of JavaScript. My question is this:

    I'm getting the page URL by using: document.location.href

    Sometimes, the URL is going to be displayed as: www.example.com/page.html#section1

    How can I remove everything after the ".html" in my variable? Is there an easy way to do this in JavaScript? If this were PHP, it would be easier for me.

    Thanks,
    Peter

    EDIT: After messing around with the code a bit, I figured it out. :)
    document.location.href.replace(/.html.*/,\".html\")
    Code (JavaScript):
     
    dp-user-1, Dec 17, 2007 IP
  2. temp2

    temp2 Well-Known Member

    Messages:
    1,231
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    150
    Digital Goods:
    2
    #2
    oh, good job
     
    temp2, Dec 18, 2007 IP