Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
"String contains an invalid character" help!
Old 07-27-2009, 11: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
 
 
Register now for full access!
Old 07-28-2009, 10:42 AM Re: "String contains an invalid character" help!
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Without some code and HTML to examine, our ability to help you is limited.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 07-30-2009, 05: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 05:39 PM.. Reason: left a bit of code out
meiamsome is offline
Reply With Quote
View Public Profile
 
Old 07-30-2009, 10:12 PM Re: "String contains an invalid character" help!
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
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.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 07-31-2009, 03: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, 04:56 PM Re: "String contains an invalid character" help!
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
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.
__________________
Join me on
Please login or register to view this content. Registration is FREE
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.82122 seconds with 12 queries