View Full Version : Animated Collapsible DIV

11-06-2007, 12:08 PM
1) Script Title: Animated Collapsible DIV

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/animatedcollapse.htm

3) Describe problem: when i load my webpage, the <div> is expanded and on clicking the collapse link, the div doesn't collapse.

...i am using this script on my Blogger blog and i uploaded the .js to a different domain...

could this be a problem? i saw this in the .js file:

window.location.href.replace("http://"+window.location.hostname, "")
i don't understand what this means yet but i was hopping somebody could tell me if setting up the .js in a different domain can cause the script to not work, so i can then start to 'decode' the .js

more so, i linked the script's src to the right url here:

<script type="text/javascript" src="animatedcollapse.js">
and double checked the entire code. everything is correct in place. the only 'fishy' thing is when i put this piece of code in the blog's <body>:

<script type="text/javascript">
var collapse1=new animatedcollapse("dog", 1000, false)

...i see this after saving:

<script type='text/javascript'>
var collapse1=new animatedcollapse(&quot;dog&quot;, 1000, false)

i tried using ' ' instead 0f " " but still i just get the code instead of the symbols


11-06-2007, 09:44 PM
The line:

window.location.href.replace("http://"+window.location.hostname, "")

only deals with persistence of a collapsible DIV's state, and not whether the script works or not when you click on a link to expand/ collapse it. Nothing you mentioned above should be applicable actually.

One reason why the .js file when uploaded to a different domain doesn't work anymore is if that host has disabled hot linking of .js files, which means the .js file doesn't even load when your calling page is on another domain. This sounds like what's happening here.

11-06-2007, 10:22 PM
hey ddadmin!

thanks f0r the inf0 0n disabling h0tlinks between d0mains.


the way this script is set up, if i were t0 put the .js's c0ntent in the <head> secti0n 0f my bl0g, instead 0f having the script targeted t0 an0ther d0main, the script sh0uld w0rk right?

11-06-2007, 11:35 PM
The key is that the src property of the <script> pointing to the .js file is to a URL on your own domain.

11-07-2007, 10:23 AM
n0, i have the src p0inting t0 the right d0main, i just didnt sh0w u which d0main it is in when i p0sted it:

edited - right n0w its 0n an h0st that accepts h0tlinks

<script type="text/javascript" src="http://www.hotlinkfiles.com/files/570843_ehca9/animatedcollapse.js">

11-07-2007, 11:33 AM

i received a resp0nse fr0m the technical department 0f the h0st im using. they d0nt supp0rt h0tlinking javascripts.

i f0und an0ther website that all0ws h0tlinking (http://www.hotlinkfiles.com) and i changed the src t0 p0int t0 the file but it still d0esnt w0rk!

i als0 tried t0 put the c0ntent 0f the .js int0 my bl0gger's html, instead 0f targeting it, and i had n0 luck there either. i just get a bunch 0f xml err0rs.

im thinking maybe the script needs t0 execute in an 0rder. since i have the expand/c0llapse piece 0f c0de 0n a 'p0st', and n0t 0n the same page as the html, where the javascript c0de is, inside it's <head>, maybe that's what screwing up the c0de...

als0, bl0gger uses this as a valid d0ctype

<?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 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'>

it has everything the c0de need t0 w0rk, being the 0nly difference in <!-- and -->

i edited the bl0g with and with0ut the signs and still the c0de remains static, with div expanded when i l0ad the page

any ideas?

11-07-2007, 07:04 PM
Hmmm please post a link to the page on your site that contains the problematic script so we can check it out.

11-07-2007, 07:20 PM

scr0ll d0wn

11-13-2007, 01:19 AM
ive unblocked the blog - sorry bout that if u tried to see it earlier

11-13-2007, 10:28 AM
The external .js file is loading, but on your HTML page, there are a series of <br> tags inside several SCRIPT tags that's causing errors. For example:

<script type="text/javascript"><br /><br />//Syntax: var uniquevar=new animatedcollapse("DIV_id", animatetime_milisec, enablepersist(true/fase), [initialstate] )<br />var collapse1=new animatedcollapse("dog", 1000, false)<br /><br /></script>

The above should be edited to something like:

<script type="text/javascript">
var collapse1=new animatedcollapse("dog", 1000, false)

Do this for all script instances on your page, which there are 3 I believe.

11-13-2007, 10:05 PM
...thats strange! hm ill have a look thanks :)

blogger automatically converted line breaks into <br>'s thats why!