Results 1 to 6 of 6

Thread: Call XMLHttpRequest

  1. #1
    Join Date
    Jun 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Call XMLHttpRequest

    Hi,

    I have a problem.
    I need to call a javascript function that the code is uses document.write.

    For example:

    function hello{
    document.write('hello')
    }

    (it's a build-in functino from a third party component that we bought).
    I would like to print the 'hello' into a specific div.
    if i call the method, it writes it the page as it is.
    Is there a way to get it to string without changing the function?

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    If you try to use document.write from a window which has loaded completely it the page will be completely repainted with the new content. So it is better if you avoid the usage of document.write in your case.

    Have a look at the below source code and see if this is what you are trying to achive.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    	<head>
    		<title>Untitled Document</title>
            <style type="text/css">
    		#content{
    			width:900px;
    			height: 100px;
    			border:1px solid red;
    			background-color: #E1E1E2;
    			font-size:small;
    			font-family:Arial, Helvetica, sans-serif;
    			color:#77AFFC;
    		}
    		</style>
    		<script type="text/javascript">
    		function insertContent(str){
    			document.getElementById('content').innerHTML = str;			
    		}
    		</script>
    	</head>
    	<body>
    		<div id="content"></div>
    		<form name="f">
    			<input type="button" value="Insert Content" onclick="insertContent('This is a test content');" name="insert" />
    		</form>
    	</body>
    </html>
    There is no point in using a subject not related to your acutal problem.

    Hope this help.

  3. #3
    Join Date
    Jun 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    it doesn't help me..
    since the function is from a third party.
    So i can't change the document.write option that it offers...
    what will be another solution to use their script without changing it?

  4. #4
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Executing their function before the window loading completes. Using an iframe might help but it is better if you can avoid them.

  5. #5
    Join Date
    Jun 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    what do you mean? if i have a timer to do it every 2 minutes, it will be after the page load!

  6. #6
    Join Date
    Jun 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    what do you mean? if i have a timer to do it every 2 minutes, it will be after the page load!

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
  •