473,396 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

innerHTML problem

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:pointer; cursor: hand;" onClick="popup = window.open ('http://example.com/abc.html?xyz=aa&abc=ssdfd',_blank','height=450,wid th=500,scrollbars=yes,resizable=yes,toolbar=yes,me nubar=yes,status=1,location=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 1525
acoder
16,027 Expert Mod 8TB
You've not defined "x" on line 5.
Nov 5 '07 #2
x is in a code somewhere above before window.onload
Nov 5 '07 #3
acoder
16,027 Expert Mod 8TB
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
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 Expert Mod 8TB
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
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 Expert Mod 8TB
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
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
i made a sample code to check the error

[HTML]<HTML>
<HEAD>
</HEAD>
<BODY>
<table>
<tr id="xyz">
<td onclick="javascript:alert('hi');">hello</td></tr>
</table>
<script>
var x=document.getElementById("xyz").innerHTML;
var temp=x.substring(0,x.indexOf("alert('")+7);
x=x.substring(x.indexOf("alert('")+7);
x="hello"+x;
x=temp+x;
alert(x);
window.onload=function(){
document.getElementById("xyz").innerHTML=x;
};
</script>
</BODY>
</HTML>
[/HTML]
this code also gave the Unknown runtime error
Nov 5 '07 #10
acoder
16,027 Expert Mod 8TB
Works in Firefox. Displays an alert "hellohi" as expected.
Nov 5 '07 #11
hmmm well the code i was working on was for IE so i didnt test it in firefox and this code is not working in IE which i want it to
Nov 5 '07 #12

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

Similar topics

6
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,...
16
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...
9
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...
2
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...
8
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...
7
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....
4
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...
7
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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,...

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.