Reply
"String contains an invalid character" help!
Old 07-27-2009, 10:07 PM "String contains an invalid character" help!
meiamsome's Avatar
Novice Talker

Posts: 11
Trades: 0
Hello,

I have a script that loops through all the div tags in a page and reads there innerHTML into a array.
the problem i have is i get this error:
Error: uncaught exception: [Exception... "String contains an invalid character" code: "5" nsresult: "0x80530005 (NS_ERROR_DOM_INVALID_CHARACTER_ERR)"]
and its really annoying me the innerHTML is "test test" (without quotations) it errors when it reaches the space i beleive can you help me to know why and how to fix it?
meiamsome is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 07-28-2009, 09:42 AM Re: "String contains an invalid character" help!
wayfarer07's Avatar
I like pie

Posts: 3,369
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Without some code and HTML to examine, our ability to help you is limited.
__________________
Wayfarer | jQuery Tooltip | Mapbox: the jQuery Map
Latest Project: Houston Movers
If Google is the Coca-Cola of Web search, Bing is RC Cola
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 07-30-2009, 04:37 PM Re: "String contains an invalid character" help!
meiamsome's Avatar
Novice Talker

Posts: 11
Trades: 0
oh, ok then
well what i was trying to do was to add an image in after the page has loaded
Code:
var attribute="";
var value="";
var mode=0;
for(i=0; i<document.getElementsByTagName("div").length; i+=1) {
 if(document.getElementsByTagName("div").item(i).id=="imagecontainer") {
  var stringarray=document.getElementsByTagName("div").item(i).innerHTML.split("")
  document.getElementsByTagName("div").item(i).innerHTML="<img id='curimage' />";
  for(a=0;a<stringarray.length;a+=1) {
   if(mode=0) {
    if(stringarray[a]==' '){
     mode=1;
    } else {
     attribute=attribute+stringarray[a];    
    }
   } else {
    if(stringarray[a]==" ") {
     document.getElementById("curimage").setAttribute(attribute,value);
     mode=0;
     attribute=""
     value=""
    } else {
     value+=stringarray[a];
    }
   }
  }
 document.getElementById("curimage").removeAttribute("id");
 }
}
and the div tag is like this:
Code:
<div id="imagecontainer">test test</div>

Last edited by meiamsome; 07-30-2009 at 04:39 PM.. Reason: left a bit of code out
meiamsome is offline
Reply With Quote
View Public Profile
 
Old 07-30-2009, 09:12 PM Re: "String contains an invalid character" help!
wayfarer07's Avatar
I like pie

Posts: 3,369
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
check out this line:
Code:
if(mode=0) {
You must mean:
Code:
if(mode==0) {
Although the first example is still valid, it will always return true, which is not your intention I can tell.
__________________
Wayfarer | jQuery Tooltip | Mapbox: the jQuery Map
Latest Project: Houston Movers
If Google is the Coca-Cola of Web search, Bing is RC Cola
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 07-31-2009, 02:12 PM Re: "String contains an invalid character" help!
meiamsome's Avatar
Novice Talker

Posts: 11
Trades: 0
I dont know how i made such an error, and didn't see it.
meiamsome is offline
Reply With Quote
View Public Profile
 
Old 07-31-2009, 03:56 PM Re: "String contains an invalid character" help!
wayfarer07's Avatar
I like pie

Posts: 3,369
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Very common error actually, but sometimes all it takes is a fresh pair of eyes to spot it.
__________________
Wayfarer | jQuery Tooltip | Mapbox: the jQuery Map
Latest Project: Houston Movers
If Google is the Coca-Cola of Web search, Bing is RC Cola
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to "String contains an invalid character" help!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.09996 seconds with 13 queries