SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2010
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Content Not Being Display

    How do I prevent my Link from disappearing??
    When I click on the link, "Click Here"

    It display, "Look At Me!!" but the link, "Click Here" is GONE
    Is there a way to keep my link, "Click Here" from disappearing?
    So when I click on the link, "Click Here" the content, "Look At Me!!" should display as well.
    thanks


    Here are my codes
    HTML Code:
    <html>
    <head>
    
    <script type="text/javascript"> 
    function display() {
       document.writeln("Look At Me!!");
    }
    </script>
    </head>
    
    <body>
    <a href="google.com" onClick="display()">Click Here</a>
    </body>
    
    </html>

  2. #2
    SitePoint Zealot Gar onn's Avatar
    Join Date
    Feb 2011
    Location
    Belgium
    Posts
    130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    useing document.write will create a new document that is replaced with the origional document (the one that contains the link).
    The solution here would be append child or innerHTML changes

  3. #3
    SitePoint Addict
    Join Date
    Apr 2011
    Posts
    266
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    Use something like this:
    HTML Code:
    <html>
    <head>
    
    <script type="text/javascript"> 
    function display(idt) {
       document.getElementById(idt).innerHTML = 'Look At Me!!';
       return false;
    }
    </script>
    </head>
    
    <body>
    <div id="rejs"></div>
    <a href="google.com" onClick="return display('rejs')">Click Here</a>
    </body>
    
    </html>
    Free: Web Programming Courses HTML, CSS, Flash
    Web Programming: AJAX Course and PHP-MySQL Course video Lessons
    Good JavaScript and jQuery course for beginners

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2010
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this work perfect
    tks guys

  5. #5
    SitePoint Enthusiast
    Join Date
    Jun 2010
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    .innerHTML is used when you trigger an event but if you just want to display the text how would you go about do it??
    I don't want to used document.writeln because it will "Wipe out all the contents" of that page.
    So I have some HTML text and javascript text. I would like both to display on my page.

    Here's my code

    HTML Code:
    <html>
    <head>
    
    <script type="text/javascript"> 
    function display() {
       document.writeln("How do I make both text appear");
    }
    </script>
    </head>
    
    <body onload="display()">
    I would like this text in the body to remain.
    
    <script type="text/javascript">
       display();
    </script>
    
    
    </body>
    </html>
    thanks

  6. #6
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    336
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    HTML Code:
    <!DOCTYPE html>
    <html>
    	<head>
    	</head>
    	<body>
    		I would like this text in the body to remain.
    
    		<script>
    			window.onload = function() {
    				var currBody = document.body;
    				currBody.innerHTML = 'How do I make both text appear' + currBody.innerHTML;
    			};
    		</script>
    	</body>
    </html>


Bookmarks

Posting Permissions

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