PDA

View Full Version : Problem w/ Pausing Up-Down Scroller script



DDTorn
12-19-2008, 05:17 AM
1) Script Title: Pausing Up-Down Scroller

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex2/crosstick.htm

3) Describe problem: Greetings to all DDF users! This is my first post. I am trying to insert this script on a blog but an error message always appears saying that 'the model is invalid because the <div> code appears inside the <head> code'... I have been trying to solve this problem for the last hours and think the issue takes place in the language used... Here's the relevant code part:


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html expr:dir='data:blog.languageDirection' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'>

<head>
<b:include data='blog' name='all-head-content'/>

<!-- PAUSING UP-DOWN SCROLLER SCRIPT -->
<style type="text/css">

[...] // i haven't changed anything in the script code

</script>
<!-- END SCRIPT -->

<title><data:blog.pageTitle/></title>
<b:skin><![CDATA[/*

[...]

I noticed that there are some <div> tags inside the script code. I think that the problem comes probably from those tags...
Can anyone know what really is the problem and how to solve it?!
Thanks in advance! :)

jscheuer1
12-19-2008, 05:54 AM
What error? Is it in the browser, or some third party validation? Does the scroller work? If so, don't worry about it unless the browser is giving an error, which it shouldn't for what you've mentioned.

If you are concerned about validation though, you can make the script (the javascript code itself) an external javascript file. General guidelines for that:


Use a text editor to save the script, call it 'file_name.js' where 'file_name' can be any valid file name of your choosing. Substitute the name of your external .js file for some.js in the below:


<script src="some.js" type="text/javascript"></script>

Common problems arise when:

1 ) The script file is not in the directory specified. In the above example it must be in the same directory as the page(s) that use it. Below, it can be in the scripts directory off of the root of a domain:


<script src="http://www.somedomain.com/scripts/some.js" type="text/javascript"></script>

2 ) Opening, closing and/or 'hiding' tags are left in the external file. This means that you must strip:
<script>
<!--and
//-->
</script>and any of their many variations from the beginning and end of the external file.

3 ) The external call (<script src="some.js" type="text/javascript"></script>) is not inserted into the page at the correct spot. The external call must be inserted at the same place on the page where the script was/would have been.

4 ) Paths to other files (if) used by the script are no longer valid due to its location. This is only a problem if the external script is kept in a different directory than the page it was working on when it was an internal script. To correct this, use absolute paths inside the script. Absolute path examples:


http://www.somedomain.com/images/button.gif

http://www.somedomain.com/~mysitename/index.html

5 ) Inappropriately combining two or more scripts into one external file. Usually external scripts can be combined if one knows enough about scripting to do so properly. Even then it is possible to overlook something.

A rule of thumb when testing is, if it won't work on the page, it won't work as an external file either.

One other thing, if this is a DD script or any script that requires the credit remain for legal use, include the credit in the on page call, ex:


<script src="some.js" type="text/javascript">
/***********************************************
* IFrame SSI script II- Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/
</script>

Make sure to retain all the 'decorations', as these include begin and end javascript comment delimiters, without which the script won't function.

There is also info here:

http://www.javascriptkit.com/javatutors/external.shtml

ddadmin
12-19-2008, 06:27 AM
Are you talking about validation errors (versus actual errors that halt the script from working)? As long as you're calling the invocation code (ie: new pausescroller(pausecontent, "pscroller1", "someclass", 3000)) in the BODY of your page, the dynamically written DIV will be output to the BODY, the correct location within the page.

DDTorn
12-19-2008, 04:08 PM
jscheuer1 and ddadmin i think the problem is a validation error... i guess it's because of having <div>'s inside the <head> code... but DD says to insert the script in the <head> section, so i don't know what to do... i followed the DD explanation of the script and i've put the 'step 1' code inside the <head> code of the page and 'step 2' code in a new blog post (which belongs to body's page), i think i've done the work like it explains... jscheuer1 i've also tried to follow your sugestions but as i'm new to this things i don't know if i'm doing anything wrong...

i have copied the script code (in DD page step 1) and paste it in a new text document and saved it in windows' desktop with the name 'scroller.js'... is it ok to save it here?
then i've inserted these lines below the following code on my page:


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html expr:dir='data:blog.languageDirection' xmlns='http://www.w3.org/1999/xhtml' xmlns:b='http://www.google.com/2005/gml/b' xmlns:data='http://www.google.com/2005/gml/data' xmlns:expr='http://www.google.com/2005/gml/expr'>

<head>
<b:include data='blog' name='all-head-content'/>

<script src="scroller.js" type="text/javascript"></script>

<title><data:blog.pageTitle/></title>
<b:skin><![CDATA[/*

[...]

and then i've inserted 'DD page step 2' code in a blog post... there have been no validation errors but nothing appeared on my blog's post too... i am doing anything wrong??

jscheuer1
12-19-2008, 04:46 PM
Was the script working before you made it external? If so, simply go back over the guidelines to find your error. Remember, only the script code goes in the external file, not the styles or script tags. If the script wasn't working before, we need to go back to how it was then and find the real error. If you want more help:

Please post a link to the page on your site that contains the problematic code so we can check it out.

DDTorn
12-20-2008, 04:54 PM
thank you once again for your help but i really can't solve the problem.. it's my first experience on editing web pages and i am new to this things, so probably the problem is obvious but i'm not finding it out.. here's the blog's link and its html's model structure: link (http://myblogskygra96.blogspot.com/), html (http://freetexthost.com/zupzl1zlxp).

jscheuer1
12-20-2008, 05:08 PM
This (from your page's served source code):


<script type="text/javascript"><br /><br />//new pausescroller(name_of_message_array, CSS_ID, CSS_classname, pause_in_miliseconds)<br /><br />new pausescroller(pausecontent, "pscroller1", "someclass", 3000)<br />document.write("<br />")<br />new pausescroller(pausecontent2, "pscroller2", "someclass", 2000)<br /><br /></script>

Needs to be:


<script type="text/javascript">
//new pausescroller(name_of_message_array, CSS_ID, CSS_classname, pause_in_miliseconds)
new pausescroller(pausecontent, "pscroller1", "someclass", 3000);
document.write("<br />");
new pausescroller(pausecontent2, "pscroller2", "someclass", 2000);
</script>

and the main pausescroller script needs to be on or linked to the page.

The code that you call your html is just a page that assembles various other files into itself to create the HTML for the page. The above error is on one of those included files, or caused by it.

DDTorn
12-21-2008, 08:06 AM
jscheuer1 thank you once again! you are giving me some lights and i've replaced the code like you said but still nothing happens... and about the main pausescroller script i don't know how to do that 'link' to the blog that you're talking about (i guess you're refering to the step of linking that long script's code to the blog). i think i have to do it on that 'assembler page', but i have no ideia how to do it and how to create any external files for it and how to link them to the page... are you understanding what i'm trying to ask you?

jscheuer1
12-21-2008, 03:46 PM
Now I don't see:


<script type="text/javascript">
//new pausescroller(name_of_message_array, CSS_ID, CSS_classname, pause_in_miliseconds)
new pausescroller(pausecontent, "pscroller1", "someclass", 3000);
document.write("<br />");
new pausescroller(pausecontent2, "pscroller2", "someclass", 2000);
</script>

In your source code at all. It also doesn't show up in your scripts at all. And this:


<script src='script.js' type='text/javascript'></script>


is a 404 not found.

I do see a lot of:


<a href='http://myblogskygra96.blogspot.com/2008/12/new-pausescrollernameofmessagearray.html'>New</a>


and similar. But that page also has none of the code on or linked to it that we need for the scroller.

And I do see:


WidgetManager._Init('http://www.blogger.com/rearrange?blogID=8994178888109473980', 'http://myblogskygra96.blogspot.com/2008/12/new-pausescrollernameofmessagearray.html','89941 . . .

In your widget manager script (it also appears in about the same form once more in that script). But unless you are using some other scroller that works off of that (not the Dynamic Drive script you were asking about), that code would be useless. If you were trying to use another scroller and abandoned it, perhaps you forgot to remove it from the widget code.