PDA

View Full Version : Marquee & external.js file.



Webiter
08-02-2011, 11:45 PM
I want to use the Dynamic Drive Cross Browser Marquee Script- on a number of pages on a Website.

I would like to install the
var marqueecontent='<nobr>Message in Here</nobr>'
within a div on each of the pages.

Can the main bulk of the controlling script for this var go an external .js file?
How might this be done?

jscheuer1
08-03-2011, 01:03 AM
Using a text only editor like NotePad place the contents of Step 1 in a file. Remove the opening:


<script language="JavaScript1.2">

and the closing:


</script>

tags. Save it as cross_marq.js and put it in the same folder as your pages. On each page where you want the marquee to appear, put:


<div><script src="cross_marq.js" type="text/javascript">
/*
Cross browser Marquee script- Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and Terms Of Use, visit http://www.dynamicdrive.com
Credit MUST stay intact
*/
</script></div>

Example:


<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
Some content here.
<div><script src="cross_marq.js" type="text/javascript">
/*
Cross browser Marquee script- Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and Terms Of Use, visit http://www.dynamicdrive.com
Credit MUST stay intact
*/
</script></div>
Some other content here.
</body>
</html>

Webiter
08-03-2011, 10:01 AM
Hi John,

Thanks for the reply and direction. I have followed same but as yet no joy!
The script installation <script src="cross_marq.js" type="text/javascript"> will not call the cross_marq.js for some reason! I have placed it in the same file as my pages and included all the code less the opening and closing tags. I appear to be making hard work out of this! Any pointers that might dig me out.:confused:

Regards.

jscheuer1
08-03-2011, 10:17 AM
Works here:

http://home.comcast.net/~jscheuer1/side/marquee/marquee_ext.htm

If you want more help:

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

Webiter
08-03-2011, 07:15 PM
Thanks it is now working a treat. Not sure what I was doing earlier but I was missing something.:mad:

(1) Just to extend the question a little further.......
Does it require major alterations to facilitate a different message being presented on each page without having to provide seperate .js files to acomplish ?

(2) I am also using W3C Mark Up Validating Service on my pages. I encounter the following message when I upload pages with the /*Cross browser Marquee script- Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and Terms Of Use, visit http://www.dynamicdrive.com
Credit MUST stay intact*/ installed.

Sorry, I am unable to validate this document because on line 50 it contained one or more bytes that I cannot interpret as utf-8 (in other words, the bytes found are not valid values in the specified Character Encoding). Please check both the content of the file and the character encoding indication. The error was: utf8 "\xA9" does not map to Unicode .

The page validates when the content between the /*xxx*/ is removed!

I would still like to present the W3C Validation <a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a> icon on the finished web pages.


How should I deal with this matter?

Regards.

jscheuer1
08-04-2011, 02:15 AM
The second question first as the credit is required. The easiest way to fix that is to change the:



to:

(c)



Back to the first question. You can have separate marquees by defining them for each page. Change this in the external script:


var marqueecontent='<nobr>Whatever Was Here Was Showing on All Pages</nobr>'

to:


var marqueecontent;
if(document.getElementById('marquee') && document.getElementById('marquee').innerHTML){
marqueecontent = '<nobr>' + document.getElementById('marquee').innerHTML + '</nobr>';
} else {
marqueecontent='<nobr>Whatever Was Here Was Showing on All Pages</nobr>'
}

That second marqueecontent= will be the default content - What's shown if there's nothing like the below highlighted on the page.

Now you can do like so for a typical page:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>External Marquee - Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
#marquee {
display: none;
}
</style>
</head>
<body>
<div>Some content here.</div>
<div id="marquee">Whatever is Here Shows for Just This Page</div>
<div><script src="cross_marq.js" type="text/javascript">
/*
Cross browser Marquee script- (c) Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and Terms Of Use, visit http://www.dynamicdrive.com
Credit MUST stay intact
*/
</script></div>
<div>some other content here.</div>
</body>
</html>

Webiter
08-11-2011, 11:37 AM
Thanks John,

Your assistance has been a great benefit.

Webiter
08-14-2011, 08:31 PM
Just noticed while testing across different browsers that the Dynamic Drive "Cross browser Marquee script-" is leaving a trail after itself in Chrome and it goes much faster in IE. Link at webitry.net
Is there a fix to workaround these items?

jscheuer1
08-15-2011, 02:34 AM
There's no marquee at that link. And since it's also a commercial site, I'm delinking it.

There's no trail in Chrome on my demo:

http://home.comcast.net/~jscheuer1/side/marquee/marquee_ext.htm

I do see it moving faster in IE though. To slow it down in IE you could (additions highlighted):


*
Cross browser Marquee script- ? Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and Terms Of Use, visit http://www.dynamicdrive.com
Credit MUST stay intact
*/

//Specify the marquee's width (in pixels)
var marqueewidth="300px"
//Specify the marquee's height
var marqueeheight="25px"
//Specify the marquee's marquee speed (larger is faster 1-10)
var marqueespeed=2
/*@cc_on @*/
/*@if(@_jscript_version >= 5)
marqueespeed=1
@end @*/
//configure background color:
var marqueebgcolor="#DEFDD9"
//Pause marquee onMousever (0=no. 1=yes)?
var pauseit=1

However, it might be better to use something like:

http://www.dynamicdrive.com/dynamicindex2/crawler/index.htm

where I believe the speed differential will be less if any.

Webiter
08-15-2011, 12:05 PM
My appologies,
link should be have been followed by /about.html for the blue trail example. Not commercial just yet as I am trying to get something going in a market that is in the heat of recession. Emigration is the other choice and to where! Do please delink as appropriate.
The speed issue in IE is maybe something that I could live with!

Regards.

jscheuer1
08-15-2011, 02:25 PM
Well I meant that switching to that other script might also fix the problem in Chrome. You could still have individual content for individual pages, and the main Crawler script is already external.

Now that I see the page in Chrome, I see that the trail is #bdffff colored. But that color, neither its hex value nor its decimal equivalent, appears anywhere in the page's source code, its generated source code, or in its associated stylesheets, or scripts. So I've no idea where it's coming from. Using the Crawler script may solve the problem, if so, use it.

Just tried it, it works. Download the script from:

http://www.dynamicdrive.com/dynamicindex2/crawler/index.htm

and put its tag in the head of the page as instructed. Then replace:


<script src="cross_marq.js" type="text/javascript">
/*Cross browser Marquee script- (c) Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and Terms Of Use, visit http://www.dynamicdrive.com
Credit MUST stay intact*/
</script>

with:


<div class="marquee" id="mycrawler"><b>To Webactivate your Business for the future......<i>call 087 7884703</i></b></div>
<!--[if lt IE 8]>
<br>
<![endif]-->
<script type="text/javascript">
(function(){
var el = document.getElementById('mycrawler'), baseHTML = el.innerHTML,
spacer = '<span style="width:150px;display:inline-block;">&nbsp;</span>';
el.innerHTML = spacer + baseHTML + spacer + baseHTML;
})();
marqueeInit({
uniqueid: 'mycrawler',
style: {
'padding': '1px',
'width': '100%',
'background': '#fff'
},
inc: 1 //speed - pixel increment for each iteration of this marquee's movement
});
</script>

The script portion of which could be made external.