PDA

View Full Version : Dynamic Ajax Content and Javascript



edandrea
10-30-2007, 06:16 PM
Dynamic Ajax Content and Javascript

2) http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm


3) I cant seem to get the javascript to work. I have tried the 'PollC' that I had read about, but that seems to just bring up the scroll on its own. The content page to be loaded works fine on its own, I am pretty sure its nothing to do with LoadObj.

On my index.php file I have the javascript file:
Head Section:
<script type="text/javascript" src="tigra_scroller/sample2/ts_files/scroll.js"></script>

Body Section:
<div id="contentarea">
<script type="text/javascript">ajaxpage('home.html', 'contentarea'); //load "home.html" into "contentarea" DIV
</script></div>

Html Page Loaded into 'Contentarea' has a script within the body:
<table border="0" cellpadding="3" cellspacing="1" align="center" bgcolor="#336699">
<tr><td class="header2" width="150">Vertical, Autoscroll Mode</td></tr>
<tr><td bgcolor="#ffffff" width="150"><SCRIPT LANGUAGE="JavaScript">Tscroll_init (0)</SCRIPT></td></tr>
</table>

I did try using a <div> with a unique id but no go.

Any ideas,
thanks in advance

jscheuer1
10-31-2007, 04:52 PM
Please post a link to the page on your site that contains the problematic code so we can check it out.

edandrea
10-31-2007, 05:11 PM
Hi,
I have changed out the old script I was using and now using the Cross Browser marquee II ( http://www.dynamicdrive.com/dynamicindex2/cmarquee2.htm ) with the Dynamic Ajax Content in the event it would work since there was no .js on the page loading. I have been fooling around with the pollcontent, but still have not suceeded.

http://www.raceforaydan.com

the page loading is http://www.raceforaydan.com/thermoindex.html

I would really appreciate any help you may provide.

edandrea
10-31-2007, 05:17 PM
I also get a javascript error 'object required' cross_marquee.style.top=0

jscheuer1
11-01-2007, 05:04 AM
First off, remove this from the script:


window.onload=initializemarquee

Then at the bottom of your thermoindex.html page, add (red):


<td><img src="images/spacer.gif" width="5" /></td>

</tr>
<tr><td colspan="2"><img onload="initializemarquee();" src="images/spacer.gif" height="5" /></td></tr>

</table>

</body>
</html>

edandrea
11-01-2007, 09:23 AM
Cool. I did attempt locally to take out the 'onLoad' but only to place it in the <body> after reading through the faq's and your writing on basic Ajax properties and applying 'pollC'. I would never have guessed where to have placed the "initializemarquee()"

Fantastic, it is working. I tried hard to fix it on my own.

Should I be concerned with the error in the document?
line 51 (cross_marquee.style.top=0) 'object required'

I am curious.

If not Thank you very much.

jscheuer1
11-01-2007, 09:35 AM
It should go away if you follow the first part of my instructions:


First off, remove this from the script:


window.onload=initializemarquee

edandrea
11-01-2007, 10:14 AM
Sorry, but it has not fixed it. I have checked my local and serverfiles and it has been removed.

I dont want to guess but would it have anything to do with this?

window.attachEvent("onload", initializemarquee)

Just a shot in the dark.

edandrea
11-01-2007, 11:05 AM
I removed this part of the script and now no error, do you think this is ok to use? Or will it mess up something else?

if (window.addEventListener)
window.addEventListener("load", initializemarquee, false)
else if (window.attachEvent)
window.attachEvent("onload", initializemarquee)
else if (document.getElementById)

jscheuer1
11-01-2007, 11:52 AM
Oh yeah, I must have missed that. All that code does is load (initialize) the script. Since you are loading the script via an image that appears with and slightly after the content that the script is intended to work with, when and if that content is added, it's fine to remove that other initialization code.

In fact, you should get rid of it.

edandrea
11-01-2007, 01:27 PM
I appreciate all your help. I did alot of trial and error stuff and this has been another learning experiance.

Thanks Heaps.

Emil