By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,818 Members | 2,121 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,818 IT Pros & Developers. It's quick & easy.

Problem setting string in array (IE)

P: 3
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?
Sep 11 '06 #1
Share this Question
Share on Google+
3 Replies


Banfa
Expert Mod 5K+
P: 8,916
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.
Sep 11 '06 #2

P: 3
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');
Sep 11 '06 #3

P: 3
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.
Sep 11 '06 #4

Post your reply

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