JohnPaddock
asked on
document.write causes the ie page to go blank?
I have a javascript function that a jsp file calls with an onclick event.
Everthing works great, however when clicking the link in ie, the page goes blank (the fuction works though). hitting F5 brings it back, but how can I avoid the page going blank? It seems to be the document.write line below that causes this. Is there a better way to do whatever that line is doing? maybe a different command other than document.write?
function IA_dialer2(number)
{
document.write("<object id='theobj' classid='clsid:0389FBBA-6E 36-4F5D-9B 9D-C702E38 07B7F'></o bject>");
........
}
Everthing works great, however when clicking the link in ie, the page goes blank (the fuction works though). hitting F5 brings it back, but how can I avoid the page going blank? It seems to be the document.write line below that causes this. Is there a better way to do whatever that line is doing? maybe a different command other than document.write?
function IA_dialer2(number)
{
document.write("<object id='theobj' classid='clsid:0389FBBA-6E
........
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Seems pretty (although I'm not sure about document.body to be an object right now).
Have you tried to load a simple page with the <object> tag on IE to see if the problem is related to the java component and the IE java addon?
Have you tried to load a simple page with the <object> tag on IE to see if the problem is related to the java component and the IE java addon?
ASKER
When I use the below line, I get the error that is below.
document.getElementByTagNa me("body") .innerHTML += "<object id='theobj' classid='clsid:0389FBBA-6E 36-4F5D-9B 9D-C702E38 07B7F'></o bject>";
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC LM 8; .NET4.0C; .NET4.0E)
Timestamp: Thu, 12 Apr 2012 17:24:19 UTC
Message: Object doesn't support this property or method
Line: 9225
Char: 1
Code: 0
URI: http://interactionapp/IA_SCRIPTS/InterAction.js
when I use tommyboys code, the page doesn't load and gives the below errors
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC LM 8; .NET4.0C; .NET4.0E)
Timestamp: Thu, 12 Apr 2012 17:32:34 UTC
Message: Expected ')'
Line: 9224
Char: 33
Code: 0
URI: http://interactionapp/IA_SCRIPTS/InterAction.js
Message: Object expected
Line: 160
Char: 2
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: 'IA_resize' is undefined
Line: 180
Char: 2
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: Object expected
Line: 1
Char: 1
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: Object expected
Line: 1
Char: 1
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: Object expected
Line: 1
Char: 1
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: Object expected
Line: 1
Char: 1
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: 'IA_resizeIdx' is undefined
Line: 5698
Char: 5
Code: 0
URI: http://interactionapp/IA_SCRIPTS/grid2.js
Message: Object expected
Line: 1
Char: 1
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: 'IA_resizeIdx' is undefined
Line: 5698
Char: 5
Code: 0
URI: http://interactionapp/IA_SCRIPTS/grid2.js
Message: Object expected
Line: 1
Char: 1
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: 'IA_resizeIdx' is undefined
Line: 5698
Char: 5
Code: 0
URI: http://interactionapp/IA_SCRIPTS/grid2.js
Message: Object expected
Line: 1
Char: 1
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: 'IA_resizeIdx' is undefined
Line: 5698
Char: 5
Code: 0
URI: http://interactionapp/IA_SCRIPTS/grid2.js
Message: 'IA_resizeIdx' is undefined
Line: 5698
Char: 5
Code: 0
URI: http://interactionapp/IA_SCRIPTS/grid2.js
Message: Object expected
Line: 1
Char: 1
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: 'IA_resizeIdx' is undefined
Line: 5698
Char: 5
Code: 0
URI: http://interactionapp/IA_SCRIPTS/grid2.js
Message: 'IA_resizeIdx' is undefined
Line: 5698
Char: 5
Code: 0
URI: http://interactionapp/IA_SCRIPTS/grid2.js
Message: Object expected
Line: 1
Char: 1
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: 'IA_resizeIdx' is undefined
Line: 5698
Char: 5
Code: 0
URI: http://interactionapp/IA_SCRIPTS/grid2.js
Message: 'IA_resizeIdx' is undefined
Line: 5698
Char: 5
Code: 0
URI: http://interactionapp/IA_SCRIPTS/grid2.js
Message: Object expected
Line: 136
Char: 3
Code: 0
URI: http://interactionapp/IA_SCRIPTS/ia_init.js
document.getElementByTagNa
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC LM 8; .NET4.0C; .NET4.0E)
Timestamp: Thu, 12 Apr 2012 17:24:19 UTC
Message: Object doesn't support this property or method
Line: 9225
Char: 1
Code: 0
URI: http://interactionapp/IA_SCRIPTS/InterAction.js
when I use tommyboys code, the page doesn't load and gives the below errors
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC LM 8; .NET4.0C; .NET4.0E)
Timestamp: Thu, 12 Apr 2012 17:32:34 UTC
Message: Expected ')'
Line: 9224
Char: 33
Code: 0
URI: http://interactionapp/IA_SCRIPTS/InterAction.js
Message: Object expected
Line: 160
Char: 2
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: 'IA_resize' is undefined
Line: 180
Char: 2
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: Object expected
Line: 1
Char: 1
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: Object expected
Line: 1
Char: 1
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: Object expected
Line: 1
Char: 1
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: Object expected
Line: 1
Char: 1
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: 'IA_resizeIdx' is undefined
Line: 5698
Char: 5
Code: 0
URI: http://interactionapp/IA_SCRIPTS/grid2.js
Message: Object expected
Line: 1
Char: 1
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: 'IA_resizeIdx' is undefined
Line: 5698
Char: 5
Code: 0
URI: http://interactionapp/IA_SCRIPTS/grid2.js
Message: Object expected
Line: 1
Char: 1
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: 'IA_resizeIdx' is undefined
Line: 5698
Char: 5
Code: 0
URI: http://interactionapp/IA_SCRIPTS/grid2.js
Message: Object expected
Line: 1
Char: 1
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: 'IA_resizeIdx' is undefined
Line: 5698
Char: 5
Code: 0
URI: http://interactionapp/IA_SCRIPTS/grid2.js
Message: 'IA_resizeIdx' is undefined
Line: 5698
Char: 5
Code: 0
URI: http://interactionapp/IA_SCRIPTS/grid2.js
Message: Object expected
Line: 1
Char: 1
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: 'IA_resizeIdx' is undefined
Line: 5698
Char: 5
Code: 0
URI: http://interactionapp/IA_SCRIPTS/grid2.js
Message: 'IA_resizeIdx' is undefined
Line: 5698
Char: 5
Code: 0
URI: http://interactionapp/IA_SCRIPTS/grid2.js
Message: Object expected
Line: 1
Char: 1
Code: 0
URI: http://interactionapp/InterAction/myContacts?proxyAccount=
Message: 'IA_resizeIdx' is undefined
Line: 5698
Char: 5
Code: 0
URI: http://interactionapp/IA_SCRIPTS/grid2.js
Message: 'IA_resizeIdx' is undefined
Line: 5698
Char: 5
Code: 0
URI: http://interactionapp/IA_SCRIPTS/grid2.js
Message: Object expected
Line: 136
Char: 3
Code: 0
URI: http://interactionapp/IA_SCRIPTS/ia_init.js
ASKER
I'm not sure if this answers your question, but when I put the below text in an html file and open the page, it works (after an activex warning)
<object id="theobj" classid="clsid:0389FBBA-6E 36-4F5D-9B 9D-C702E38 07B7F"></o bject>
<script>
var sNewText = "8465";
if(sNewText.length <= 32)
{
if(sNewText == "")
{
}
theobj.StartVoiceCall(sNew Text);
}
else
{
alert("dd");
}
</script>
<object id="theobj" classid="clsid:0389FBBA-6E
<script>
var sNewText = "8465";
if(sNewText.length <= 32)
{
if(sNewText == "")
{
}
theobj.StartVoiceCall(sNew
}
else
{
alert("dd");
}
</script>
Fix the first error and the others may go away. You have a parenthesis missing somewhere.
Message: Expected ')'
Line: 9224
Char: 33
Code: 0
You could also as a test try something like this just to see if you are attempting to run the code before the body even exist in the DOM:
if(document.body != null){
var newDiv = document.createElement('di v');
newDiv.appendChild('<objec t id='theobj' classid='clsid:0389FBBA-6E 36-4F5D-9B 9D-C702E38 07B7F'></o bject>');
document.body.appendChild( newDiv');
}else{
alert("body null");
}
Message: Expected ')'
Line: 9224
Char: 33
Code: 0
You could also as a test try something like this just to see if you are attempting to run the code before the body even exist in the DOM:
if(document.body != null){
var newDiv = document.createElement('di
newDiv.appendChild('<objec
document.body.appendChild(
}else{
alert("body null");
}
ASKER
I revised tommyboys code by adding a ' before the newdiv, and changing some single quotes to double quotes.
var newDiv = document.createElement('di v');
newDiv.appendChild("<objec t id='theobj' classid='clsid:0389FBBA-6E 36-4F5D-9B 9D-C702E38 07B7F'></o bject>");
document.body.appendChild( 'newDiv');
not it gives this error
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC LM 8; .NET4.0C; .NET4.0E)
Timestamp: Thu, 12 Apr 2012 18:02:42 UTC
Message: Type mismatch.
Line: 9224
Char: 1
Code: 0
URI: http://interactionapp/IA_SCRIPTS/InterAction.js
var newDiv = document.createElement('di
newDiv.appendChild("<objec
document.body.appendChild(
not it gives this error
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MS-RTC LM 8; .NET4.0C; .NET4.0E)
Timestamp: Thu, 12 Apr 2012 18:02:42 UTC
Message: Type mismatch.
Line: 9224
Char: 1
Code: 0
URI: http://interactionapp/IA_SCRIPTS/InterAction.js
ASKER
I tried using the code you mentioned below, but it's giving the same type mismatch error
if(document.body != null){
var newDiv = document.createElement('di v');
newDiv.appendChild("<objec t id='theobj' classid='clsid:0389FBBA-6E 36-4F5D-9B 9D-C702E38 07B7F'></o bject>");
document.body.appendChild( 'newDiv');
}else{
alert("body null");
}
if(document.body != null){
var newDiv = document.createElement('di
newDiv.appendChild("<objec
document.body.appendChild(
}else{
alert("body null");
}
The TypeMismatch coming for IE only, correct?
Are you sure the TypeMismatch error is because of the code I suggested? Does it NOT happen when the code is commented out? TypeMismatch errors generally result in IE when adding event listeners using javascript.
Are you sure the TypeMismatch error is because of the code I suggested? Does it NOT happen when the code is commented out? TypeMismatch errors generally result in IE when adding event listeners using javascript.
The correct text for the tagname function is:
document.getElementsByTagName("body")
document.getElementsByTagName("body")
ASKER
nothing I was doing was working (I'm not a java programming at all so I was getting frustrated), so we got a consultant to fix it. I don't really know exactley what he did, but I think he moved that object id='theobj'.... line from the function in the js file, to 2 other jsp files so the object already gets loaded when the page loads so the onclick event doesn't need to load it(causing a blank line). If I was more familier with js and jsp though I'm sure I could have worked through it with your suggestions/help.
thanks
thanks
ASKER
It sounds like what the consultant did was pretty much what Bardobrave suggested in his first comment.
ASKER
the below line came from a cisco htm file
<object id="theobj" classid="clsid:0389FBBA-6E
when we added it to our js file, we had to change it to
document.write("<object id='theobj' classid='clsid:0389FBBA-6E
so I don't think I can try what you're saying since I can't control the html pages for this, but there must be a better way of 'running' the line without the document.write. maybe document.run? .run doesn't work though