Connecting Tech Pros Worldwide Forums | Help | Site Map

Problem setting string in array (IE)

Newbie
 
Join Date: Sep 2006
Posts: 3
#1: Sep 11 '06
Hello,

I'm trying to assign strings to array elements in javascript. It works in Firefox but in IE it throws "Unknown runtime error".

Expand|Select|Wrap|Line Numbers
  1. sContent = '<p>this is a features test post.</p><p><a title="test" href="http://url.com">link</a></p>';
  2.  
  3. g_ImageTable[g_imax++] = new Array ('<?php echo $sFeatureImgUrl; ?>', '<?php echo $iId; ?>', '<?php echo $sPermalink; ?>', '<?php echo $sTitle; ?>', sContent, '<?php echo $sCategory; ?>', '<?php echo $sTime; ?>', '<?php echo $sAuthor; ?>');
Then it breaks when I try to use that array entry -

Expand|Select|Wrap|Line Numbers
  1. getobject("Ath_PostContent").innerHTML = g_ImageTable[g_iimg][4];
sContent is offset 4 and in debugging, that's where it dies.

The contents of sContent at that time are

[HTML]"<p>another feature post. another feature post. another feature post. another feature post. another feature post. another feature post. another feature post. another feature post. another feature post. another feature post. another feature post. another feature post.</p>"[/HTML]
I'm not quite sure what else to try.

Any ideas?

Banfa's Avatar
AdministratorVoR
 
Join Date: Feb 2006
Location: South West UK
Posts: 6,185
#2: Sep 11 '06

re: Problem setting string in array (IE)


It would be helpful to see the actual source code that the browser is seeing rather than the code before it has been run through the PHP.
Newbie
 
Join Date: Sep 2006
Posts: 3
#3: Sep 11 '06

re: Problem setting string in array (IE)


Quote:

Originally Posted by Banfa

It would be helpful to see the actual source code that the browser is seeing rather than the code before it has been run through the PHP.

Sure thing - sorry

Expand|Select|Wrap|Line Numbers
  1. sContent = '<p>this is a features test post.</p><p><a title="test" href="http://url.com">link</a></p>';
  2. g_ImageTable[g_imax++] = new Array ('http://www.url.com/2.jpg', '4', 'http://url.com/features/this-is-a-feature-test/', 'this is a feature test', sContent, '<a href=\"http://url.com/category/features/\" title=\"View all posts in features\" rel=\"category tag\">features</a>', 'September 10th, 2006 at 8:09pm', 'optimus');
Newbie
 
Join Date: Sep 2006
Posts: 3
#4: Sep 11 '06

re: Problem setting string in array (IE)


Geez, it so happens that my .innerHTML was pointing at a span. When I changed it to a div it worked fine.

Expand|Select|Wrap|Line Numbers
  1. getobject("Ath_PostContent").innerHTML = g_ImageTable[g_iimg][4];
before:
Expand|Select|Wrap|Line Numbers
  1. <p align="center"><b>Ath_PostContent:</b> <span id="Ath_PostContent"> </span> </p>
after:
Expand|Select|Wrap|Line Numbers
  1. <p align="center"><b>Ath_PostContent:</b> <div id="Ath_PostContent"> </div> </p>
Sorry to waste anyones time.
Reply