473,789 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

document.write script errors

Hello,
When the following page is executed in IE6, it generates script errors
('object expected') for any function that is declared in an external
..js file. Why is this???? This code works in Firefox 1.07 and 1.5.
(The following code, when the body's onload event is triggered, simply
rewrites the page using documentElement .innerHTML)

//------------test.html--------------------
<html>
<head>
<script src="script.js" ></script>
<script type="text/javascript">
function rewritePage(){
alert('rewritin g the page');
document.write( document.docume ntElement.inner HTML);
}
</script>
</head>
<body onload="rewrite Page();">
generate a script error with document.write
<script type="text/javascript">
isScriptWorking (); // from script.js
</script>
</body>
</html>
//---------script.js-------------
function isScriptWorking () {
alert('script is working');
}

How can I get around this, if this is the method that I have to use?

Nov 23 '05 #1
4 1956
> document.write( document.docume ntElement.inner HTML);

Are you trying to make the page eat itself ?

This could be tricky :)

Aaron
Nov 23 '05 #2
ro***********@g mail.com wrote:
Hello,
When the following page is executed in IE6, it generates script errors
('object expected') for any function that is declared in an external
.js file. Why is this???? This code works in Firefox 1.07 and 1.5.
(The following code, when the body's onload event is triggered, simply
rewrites the page using documentElement .innerHTML)
There is no public specification for what innerHTML should do or how it
should do it - so whatever it does is whatever it does and browsers will
vary in that.

For the record, on my machine your page loads twice in Firefox before it
becomes comatose, IE re-loads the page once.
[...]
How can I get around this, if this is the method that I have to use?


Explain what you are trying to achieve and suggestions may be posted...
or not. Why you need to suck the HTML out of a document then simply
write it back again plumb evades me.

It has consequences such as you loss of the DOCTYPE, resulting in an
invalid document and it may cause IE (and perhaps other browsers) to
treat the page differently.
--
Rob
Nov 23 '05 #3
I see your (doctype/html root element) point - in my particular case, I
am actually using the xmlhttp activex object to slurp the page (for
IE); I tried to use an example that would mirror the effect w/o
displaying a client's code on a public forum.
I am performing a web app vulnerability test; this application has a
semi-public front-end, so input is filtered pretty heavily. I have
already bypassed the filters that disallow scripting of any kind, but
it is rather obvious upon viewing the page source using a browser.
I would like to show that evidence of this type of behaviour can be
further obfuscated: I am attempting, when the body's onload event is
triggered, to use a regex to remove the messy code that I have been
able to inject, and place innocuous-looking payload code elsewhere in
the document.
It works splendidly, except for the case that I'm illustrating.

Thank you for your help,
Robert

Nov 23 '05 #4
VK

ro***********@g mail.com wrote:
I see your (doctype/html root element) point - in my particular case, I
am actually using the xmlhttp activex object to slurp the page (for
IE); I tried to use an example that would mirror the effect w/o
displaying a client's code on a public forum.
I am performing a web app vulnerability test; this application has a
semi-public front-end, so input is filtered pretty heavily. I have
already bypassed the filters that disallow scripting of any kind, but
it is rather obvious upon viewing the page source using a browser.
I would like to show that evidence of this type of behaviour can be
further obfuscated: I am attempting, when the body's onload event is
triggered, to use a regex to remove the messy code that I have been
able to inject, and place innocuous-looking payload code elsewhere in
the document.
It works splendidly, except for the case that I'm illustrating.


My posts (VK) here should explain you the situation:
<http://groups.google.c om/group/comp.lang.javas cript/browse_frm/thread/c56aa6ddf79cccf 4/eb6a361cb59f6b4 d>

Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2829
by: Dennis M. Marks | last post by:
I generate a SELECT list dynamically by taking items from a table. I have DOCUMENT.WRITE statements that write a combination of literals and variables including < and > characters. The HTML seems to work all right but validators show errors of having a closing > without an opening <. Even though these are in DOCUMENT.WRITE statements within quotes they are still flagged as errors. Is there any way around this. I have tried HTML entities...
3
3340
by: Crimefighter | last post by:
I'm not a javascript guy, but the use of this banner rotator script has given me fits. I know a few causes of the problem thus far, one being the layer tags aren't supported under Netscape 7.1 just the entire 4.X series. Script works fine under IE. I've tried a few things to get it working under Netscape, such as defining a style for the bannerLayer with the style tag, and trying to define the style under the div tag, I've tried the...
4
6016
by: Bernard | last post by:
Hi, I am suddenly getting Safari script errors with the following user agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.2 (KHTML, like Gecko) Safari/125.8 In a frameset scenario, the framesetting document (top) contains a
3
3601
by: Paul Thompson | last post by:
I am working with a special tool which pre-processes the page. Using document.write, I am composing the page while it is loading, so I need to force a reprocess of the page AFTER the page loads. Is there some way to do that? That is, I want the browser to essentially act as if the composed page was the original page. Here is a brief version of the page construction technique:
12
3348
by: Radek Maciaszek | last post by:
Hi It's very interesting problem. I couldn't even find any inforamtion about it on the google. I think that the best way of explain will be this simple example: <html> <body> <script language="JavaScript" type="text/javascript" src="write.js"></script>
12
2869
by: Sean | last post by:
Hi, I have the following script: ----------------------------------------------------------------------------------- <script type="text/javaScript"> <!-- document.write('<div id=hello1>Hello1</div>'); document.write('<div id=hello2 style="display:none;"><script src="test.js"><\/script></div>');
2
3624
by: robert.waters | last post by:
Hello, I am dynamically editing the contents of a page and using document.write() to reload the new, edited content. However, on the new page, any calls to functions located in external .js files (fyi: same domain) fail with 'object expected' (IE6). If I subsequently reload the page, everything works. Also, if I inline this code, everything works. Here is an example: (called from body onload event) (This just rewrites the page with...
11
3113
by: Michael Powe | last post by:
How can I make an XHTML-compliant form of an expression in this format: document.write("<scr"+"ipt type='text/javascript' src='path/to/file.js'>"+"</scr"+"ipt>"); this turns out to be a non-trivial exercise. inserting '&lt;' and '&gt;' causes the browser to write the text to the page as literal text rather than as the intended script element. Using escape codes seemed to work (makes it standard compliant) but the text is not written to...
1
7546
by: anupamaavadutha | last post by:
hi all, iam new to javascript. i have problem calling javascript functions.iam designing a calender page.here is my code. <%@ page import='java.io.*,java.util.*,java.sql.*,javax.servlet.*,javax.servlet.http.*' session='true'%> <%@ page import='java.text.*'%> <html> <script language='javascript'> function backward() { alert("hello"); }
0
9663
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10195
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6765
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4090
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.