473,564 Members | 2,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript code within innerHTML

2 New Member
A question on "innerHTML" .

Hi,

The below is my HTML code.
ActiveX function "GetData()" returns HTML string which may include javascript codes.
This HTML string may be HTML codes in any pages which I will navigate to.

The result of the below code is not what I expected.
Error occurred in the line "divEncId.inner HTML=enc;".
And, the IE browser displays white page.
But, some pages are displayed well.


What is the problem in my code?
Someone said that the "innerHTML" is not used on the HTML string which includes javascript code. Is it right?

I appreciates who help me.

[HTML]<html>
<head>
<script language="javas cript">
function doJob()
{
var enc = document.aObj.G etData("...");

var divEncId = self.document.g etElementById(" divEnc");

// Just for debug : I confirmed the below 2 values is no problem.
alert(enc);
alert(divEncId. innerHTML);

divEncId.innerH TML=enc;
}
</script>
</head>
<body onload="javascr ipt:doJob();">
<div id="divEnc">Con tent</div>
<object id="aObj" classid="CLSID: ..." codebase="/ActivexObj.cab# Version=..." width=... height=...></object>
</body>
</html>[/HTML]
Sep 12 '07 #1
3 1819
gits
5,390 Recognized Expert Moderator Expert
hi ...

welcome to TSDN ...

could you give an example of the result you get out of your getData() method? ...

kind regards
Sep 12 '07 #2
BeginnerHyun
2 New Member
Thanks for replying me.

The example string which the ActiveX function "GetData()" returns is as below:

Expand|Select|Wrap|Line Numbers
  1. "<html><head>    <script language=\"javascript\">        function doJob1()        {            alert(\"This is test.\");        }    </script></head><body onload=\"javascript:doJob1();\"></body></html>"
This string includes script tag "<script>" and "</script>".
This is simple string, not real string. but, the result is almost same.

I've test it with the code "document.write ()" instead of "innerHTML" .
But, I can get the expected result.

What's the problem?

Regards,
Beginner in HTML, Javascript.
Sep 18 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
Changed the thread title.

You have the whole HTML page code there. Shouldn't that just be a snippet? If you want a whole page within another page, use an iframe.
Sep 18 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

53
5672
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is difficult to know what is going on. One of these Order Forms you can see here... http://www.cardman.co.uk/orderform.php3
4
5930
by: sameergn | last post by:
Hi, I have HTML form whose target is an invisible IFrame. After the IFrame is loaded completely, following code transfers contents of IFrame to DIV document.getElementById("mainDiv").innerHTML = test_iframe.document.body.innerHTML; but this does not seem to carry over the Javascript code from IFrame to
3
12857
by: analwarsi | last post by:
Hi, i am new to javascript. actually i need to execute the wget command from within a javascript code, but i don't know the syntax for executing the linux-ccommands from within javascript code. Can anyone guide please?
3
2416
by: BAnderton | last post by:
Hello all, Question: Is there any way to access a javascript variable from within psp code? I'm aware of how to do the reverse of this (js_var='<%=psp_var%>'). Here's a non-working example of what I'm trying to do:
2
2510
by: FrogBunz | last post by:
Is there a way to execute inline javascript code from within an AJAX response? I use AJAX to retrive a JSP page that is loaded using a database bean. One of the form elements is a select that I would like to set based on the database value. I've tried embedding inline script like: <script language="javascript"> document.form1.state.value...
2
6631
by: gsherp | last post by:
Is there anyway to call a javascript function within an innerHTML call? example: var someelement = document.createElement("input"); var someelement2 = document.createElement("input"); function test(str) { var str2 = test.substring(0,4); return str2; }
3
3914
by: Mike P | last post by:
I have a HTML menu that I want to add some C# code around which will include a variable declaration and an if statement. How do I add this code within my HTML? *If statement here, if true then show div <div id="idButton3" class="otherLeftBarLink" onmouseover="javascript: changeStylesMouseOver('3');" onmouseout="javascript:...
1
1685
by: swethak | last post by:
hi, i have a javascript variable var monthNum and i assigned some value in javascript.Now i use that variable in jsp as <% pstatement2 = connection.prepareStatement("Select * from importtimetable where month='"+monthNum+"'"); %> In that where condition monthNum is jascript variable. I used like that i got a error.
2
11647
by: LindaDhasan | last post by:
Hi, I am a beginner with javascript.Please help me clarify how to display the result of a javascript function within html underline tag.PFA the code. <html> <head> <script type="text/javascript"> function whichBrs() {
0
7665
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...
0
7583
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...
0
8106
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...
1
7642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5484
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...
0
3643
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...
1
2082
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
1
1200
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.