CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2006
    Posts
    228

    Function to load page

    Hello,

    I am using the following code:

    Code:
    function test()
    {
    location.href = "home.htm" ;
    }
    I want to use a function to load a page (which above is working) but I want to have a class part of the URL.

    I know I can use a link on the page like:
    Code:
     
    <a href="page.html" class="first">Link text</a>
    But I want to include class="first" part of the javascript function.

    Any ideas?

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: Function to load page

    Not sure why you would ever need this...

    Code:
    function link(elem, page) {
      var class = elem.class;
      location.href = page;
    }
    
    <a href="javascript:link(this, 'page.html')" class="first">Link text</a>
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured