473,799 Members | 3,218 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

innerHTML problem

85 New Member
i have problem with innerHTML
i get the value of innerHTML of tr and modify the text
but when i try to put this text back in innerHTML it says unknown runtime error
im trying to append some paramaeter in the onclick url

[HTML]<table bgcolor= "#FFFFFF" width="150" border="0" cellpadding="0" cellspacing="0" >
<tr id="xyz">
<td height="150" style="cursor:p ointer; cursor: hand;" onClick="popup = window.open ('http://example.com/abc.html?xyz=aa &abc=ssdfd',_bl ank','height=45 0,width=500,scr ollbars=yes,res izable=yes,tool bar=yes,menubar =yes,status=1,l ocation=yes'); return false">some code here
</td>
</tr>
</table>[/HTML]

Expand|Select|Wrap|Line Numbers
  1. window.onload=function(){
  2. var y=document.getElementById("xyz").innerHTML;
  3. var temp=y.substring(y.indexOf("window.open('")+13);
  4. y=y.substring(0,y.indexOf("window.open('")+13);
  5. y=y+temp.substring(0,temp.indexOf("'"))+"&xyzuser="+x+temp.substring(temp.indexOf("'"));
  6. document.getElementById("xyz").innerHTML=y;
  7. };
  8.  
Nov 5 '07 #1
11 1565
acoder
16,027 Recognized Expert Moderator MVP
You've not defined "x" on line 5.
Nov 5 '07 #2
rohitchawla
85 New Member
x is in a code somewhere above before window.onload
Nov 5 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
temp.indexOf("' ") on line 5 is finding the first single quote rather than the second one, so the extra parameter is added to the beginning which causes a syntax error.
Nov 5 '07 #4
rohitchawla
85 New Member
well temp start after 1st '
Expand|Select|Wrap|Line Numbers
  1. temp=y.substring(y.indexOf("window.open('")+13);
and i have used
Expand|Select|Wrap|Line Numbers
  1. alert(y);
which gave the the desired result
but when i put it in innerHTML, it gave unknown runtime error
Nov 5 '07 #5
acoder
16,027 Recognized Expert Moderator MVP
and i have used
Expand|Select|Wrap|Line Numbers
  1. alert(y);
which gave the the desired result
but when i put it in innerHTML, it gave unknown runtime error
Did you put this alert after line 5?

In your onclick, there is a space between window.open and the opening brace ( while in your code checking for the index, there isn't.
Nov 5 '07 #6
rohitchawla
85 New Member
sorry for the silly mistake
yes the alert is after line 5 and i pasted a space after window.open here for better view whereas it is not in my original code
after alert i can see the changed value
Nov 5 '07 #7
acoder
16,027 Recognized Expert Moderator MVP
Noticed a missing single quote:
Expand|Select|Wrap|Line Numbers
  1. _blank'
If you add the beginning quote, it should work.
Nov 5 '07 #8
rohitchawla
85 New Member
grrr i make a lot of mistakes when i paste my code
i removed some part from url when posting here and by mistake removed the ' before _blank as well. my code has the ' in it
Nov 5 '07 #9
rohitchawla
85 New Member
i made a sample code to check the error

[HTML]<HTML>
<HEAD>
</HEAD>
<BODY>
<table>
<tr id="xyz">
<td onclick="javasc ript:alert('hi' );">hello</td></tr>
</table>
<script>
var x=document.getE lementById("xyz ").innerHTM L;
var temp=x.substrin g(0,x.indexOf(" alert('")+7);
x=x.substring(x .indexOf("alert ('")+7);
x="hello"+x;
x=temp+x;
alert(x);
window.onload=f unction(){
document.getEle mentById("xyz") .innerHTML=x;
};
</script>
</BODY>
</HTML>
[/HTML]
this code also gave the Unknown runtime error
Nov 5 '07 #10

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

Similar topics

6
2824
by: Tim Fooy | last post by:
Hi all, I have the following problem. In my page i have a large <div> with tags inside it that have event handlers on them (onclick etc.). When i run div.innerHTML = moreText + div.innerHTML, either before or after the page has fully loaded, all of those event handlers are dropped: the actions for the event are not executed anymore. I can't find anything related to this problem on the internet. Has anyone ever encountered a similar...
16
13348
by: Joel Byrd | last post by:
I am having this ridiculous problem of trying to set the innerHTML of a div node. It works in all other browsers, but internet explorer is giving me an "Unknown runtime error". This is actually in the context of developing an auto-suggest (basically reverse-engineering Google Suggest), but I don't see how any of the other code has anything to do with it. I *pretty sure* that I've narrowed it down to 1 line (the line on which the...
9
8672
by: Hallvard B Furuseth | last post by:
Why does the FAQ (Q 4.15) recommend innerHTML when so many here say one should use createElement(), replaceChild() etc? Also, why does the "Alternative DynWrite function" at <http://www.jibbering.com/faq/faq_notes/alt_dynwrite.html> need such a lot of tests to find out if innerHTML assignment actually works, instead of just inserting <span id="strange name"></span> and checking if the document now contains an element with that ID?
2
9567
by: sveinn | last post by:
Hi all, I've read through this group searching for an answear about this problem. Few have come close but not quite what I need. My problem is this: I'm using Ajax to fetch a new table with input boxes. I then take the innerHTML from my <div> and add the new table to the existing one/s. What happens in FireFox is that all values in other tables input boxes
8
7775
by: Clément | last post by:
Hi! I am currently developping a user interface with Ajax/C#/.net. And I am facing a problem with Mozilla, and Firefox. I use the function innerHTML to load a Web UserControl into a div, this way the main page never gets refreshed. It works perfectly under IE, but with Mozilla and Firefox I got a problem : there is a space before the thing I want to display everytime I use ".innerHTML".
7
2610
by: Nez | last post by:
Help needed! Hello, I have looked everywhere for a solution to my problem and this is pretty much my last resource. I have created a table in a span with the innerhtml command in my code behind. In this table I have created textbox html input fields. Now I need to allow the user to change the value in the textfield, and compare it to the old value I have stored in a cookie. Problem is, because the textfield was created in the code...
4
5133
by: tcole6 | last post by:
My problem appears to be Firefox specific. I have a hyperlink that loads a new window. This window contains hyperlinks that call javascript functions in the parent window and then closes the child window. The function that is called contains an XMLHttpRequest. My problem is that everything happens as it should, the innerHTML is changed by the results of the XMLHttpRequest and the child window closes. The problem is this, in Firefox,...
7
38027
by: John | last post by:
Hi Everyone, I'm having this extremely annoying problem with Internet Explorer 6, giving me an error message saying "unknown runtime error" whenever I try to alter the contents of a <divelement using innerHTML. Now, I've researched this problem on the web, and found many references to it, but none of them quite addressed my specific situation, and since my experience with JavaScript is limited, I was not able to adapt the solutions I...
0
10490
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10243
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10030
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9078
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7570
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
5467
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
5590
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.