40 users online (1 members and 39 guests)  


  Results 1 to 4 of 4

Related

  1. Replies: 6
  2. Replies: 0
  3. document.write() query    Forum: Javascript Forum
    Replies: 4
  4. Replies: 7
  5. document.write question    Forum: Javascript Forum
    Replies: 5
  1. #1
    Pounder's Avatar
    New User

    Status
    Offline
    Join Date
    Jul 2003
    Posts
    2

    Javascript document.write problems

    I have code which looks something like the following:

    Code:
    	<head>
    		<title>Wonderful Website</title>
    		<script>
    			function drawLayerLogin()
    			{
    				document.write('testing...');
    			}
    		</script>
    	</head>
    	<body bgcolor="#00ffff">
    		<A href="javascript:drawLayerLogin();">Login</a>
    </body>
    but the problem is when I click the Login link the page clears and the message testing... is displayed at the top on its own and not on the original document. Eventually i want this code to draw a CSS layer over the page contining a login form so how do I make it keep the original page content?

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hi there,

    There is a method called innerHTML which would do this, but it is not very cross-browser. Therefore, I think you should use CSS.

    If you have your layer on the page. but display: none set on it, you can change the class of the layer to make it visible using JavaScript.

    Tutorial on changing classes via JavaScript -

    http://css.somepeople.net?page=dynamic
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    Pounder's Avatar
    New User

    Status
    Offline
    Join Date
    Jul 2003
    Posts
    2
    So where does changing text colours come into making layers visible?

  4. #4
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    With a little imagination.

    its an example of how to change the class of an element, so what if the two classes are -

    Code:
    .hide {
    display: none;
    }
    .show {
    display: block;
    }
    So if you can change between those classes, you get the effect of making something visible or invisible.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?