Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Junior Member
    Join Date
    Jun 2003
    Posts
    3
    Member #
    1620
    Hi

    Im new to this forum, and new to Javascript too. I have a problem. I need to have a page title change (toggle between two phrases) when i click on a button. This button already has a function, and needs to have this appended to it. Any ideas?

  2.  

  3. #2
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    welcome to the board Dave...

    you can either do two things...

    1. Put the code to change the title in the existing function

    OR

    2. Put a comma then the second function like this...
    [minicode]<a href="javascript:function1(), function2()">Link Text</a>[/minicode]

    here is the code for swapping the title anyway
    Code:
    <html>
    <head>
    <title>This is the starting title</title>
    <script type="text/javascript">
    function titleswap(titletext) {
    	document.title = titletext;
    }
    </script>
    </head>
    
    <body>
    <a href="javascript:titleswap('Hello, this is title1')">Link1</a>
    <a href="javascript:titleswap('Hello, this is title2')">Link2</a>
    </body>
    </html>
    JR

  4. #3
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    by the way ignore the spaces it puts in javascript
    JR

  5. #4
    Junior Member
    Join Date
    Jun 2003
    Posts
    3
    Member #
    1620
    Thanks for the help, im sure that I will be able to use that to help, although I think I misled you slightly in my original posting. When I said Page Title, I didnt actually mean the <TITLE>, just some text on the page that is the title for the page on screen(between <p>PAGE TITLE</p>). Sorry for the confusion, I will have to be more careful in future how I word things. Does this make much difference to the code?

    Thanks for your help

    DaveZH

  6. #5
    JR
    JR is offline
    Senior Member JR's Avatar
    Join Date
    Nov 2002
    Location
    UK
    Posts
    4,354
    Member #
    257
    LOL, my mistake...

    this should work
    Code:
    <html>
    <head>
    <script type="text/javascript">
    function titleswap(titletext) {
    	document.getElementById('pgheader').innerHTML = titletext;
    }
    </script>
    </head>
    
    <body>
    <span id="pgheader" style="font-size: 20px;">Starting Title</span>
    <br><br>
    <a href="javascript:titleswap('Hello, this is title1')">Link1</a>
    <a href="javascript:titleswap('Hello, this is title2')">Link2</a>
    </body>
    </html>
    Remember to remove the space in javascript ! ! !
    JR

  7. #6
    Junior Member
    Join Date
    Jun 2003
    Posts
    3
    Member #
    1620
    Thanks for the help - thats working just fine now. You are a star!!!!


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:07 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com