PDA

View Full Version : Cursor effects



balki
02-14-2013, 05:11 PM
Hello!
I have a problem with a script. When I use it on the page ( http://www.souhssz.com/tjestova/question/ ) the main menu disappears. Any idea why?
This is the code:


<script type='text/javascript'>
// <![CDATA[
var colour="#FF0066";
var sparkles=40;
var x=ox=400;
var y=oy=300;
var swide=800;
var shigh=600;
var sleft=sdown=0;
var tiny=new Array();
var star=new Array();
var starv=new Array();
var starx=new Array();
var stary=new Array();
var tinyx=new Array();
var tinyy=new Array();
var tinyv=new Array();
window.onload=function() { if (document.getElementById) {
var i, rats, rlef, rdow;
for (var i=0; i<sparkles; i++) {
var rats=createDiv(3, 3);
rats.style.visibility="hidden";
document.body.appendChild(tiny[i]=rats);
starv[i]=0;
tinyv[i]=0;
var rats=createDiv(5, 5);
rats.style.backgroundColor="transparent";
rats.style.visibility="hidden";
var rlef=createDiv(5, 5);
var rdow=createDiv(5, 5);
rats.appendChild(rlef);
rats.appendChild(rdow);
rlef.style.top="2px";
rlef.style.left="0px";
rdow.style.top="0px";
rdow.style.left="2px";
document.body.appendChild(star[i]=rats);
}
set_width();
sparkle();
}}
function sparkle() {
var c;
if (x!=ox || y!=oy) {
ox=x;
oy=y;
for (c=0; c<sparkles; c++) if (!starv[c]) {
star[c].style.left=(starx[c]=x)+"px";
star[c].style.top=(stary[c]=y)+"px";
star[c].style.clip="rect(0px, 5px, 5px, 0px)";
star[c].style.visibility="visible";
starv[c]=50;
break;
}
}
for (c=0; c<sparkles; c++) {
if (starv[c]) update_star(c);
if (tinyv[c]) update_tiny(c);
}
setTimeout("sparkle()", 40);
}
function update_star(i) {
if (--starv[i]==25) star[i].style.clip="rect(1px, 4px, 4px, 1px)";
if (starv[i]) {
stary[i]+=1+Math.random()*3;
if (stary[i]<shigh+sdown) {
star[i].style.top=stary[i]+"px";
starx[i]+=(i%5-2)/5;
star[i].style.left=starx[i]+"px";
}
else {
star[i].style.visibility="hidden";
starv[i]=0;
return;
}
}
else {
tinyv[i]=50;
tiny[i].style.top=(tinyy[i]=stary[i])+"px";
tiny[i].style.left=(tinyx[i]=starx[i])+"px";
tiny[i].style.width="2px";
tiny[i].style.height="2px";
star[i].style.visibility="hidden";
tiny[i].style.visibility="visible"
}
}
function update_tiny(i) {
if (--tinyv[i]==25) {
tiny[i].style.width="1px";
tiny[i].style.height="1px";
}
if (tinyv[i]) {
tinyy[i]+=1+Math.random()*5;
if (tinyy[i]<shigh+sdown) {
tiny[i].style.top=tinyy[i]+"px";
tinyx[i]+=(i%5-2)/5;
tiny[i].style.left=tinyx[i]+"px";
}
else {
tiny[i].style.visibility="hidden";
tinyv[i]=0;
return;
}
}
else tiny[i].style.visibility="hidden";
}
document.onmousemove=mouse;
function mouse(e) {
set_scroll();
y=(e)?e.pageY:event.y+sdown;
x=(e)?e.pageX:event.x+sleft;
}
function set_scroll() {
if (typeof(self.pageYOffset)=="number") {
sdown=self.pageYOffset;
sleft=self.pageXOffset;
}
else if (document.body.scrollTop || document.body.scrollLeft) {
sdown=document.body.scrollTop;
sleft=document.body.scrollLeft;
}
else if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft)) {
sleft=document.documentElement.scrollLeft;
sdown=document.documentElement.scrollTop;
}
else {
sdown=0;
sleft=0;
}
}
window.onresize=set_width;
function set_width() {
if (typeof(self.innerWidth)=="number") {
swide=self.innerWidth;
shigh=self.innerHeight;
}
else if (document.documentElement && document.documentElement.clientWidth) {
swide=document.documentElement.clientWidth;
shigh=document.documentElement.clientHeight;
}
else if (document.body.clientWidth) {
swide=document.body.clientWidth;
shigh=document.body.clientHeight;
}
}
function createDiv(height, width) {
var div=document.createElement("div");
div.style.position="absolute";
div.style.height=height+"49px";
div.style.width=width+"50px";
div.style.overflow="hidden";
div.style.backgroundColor=colour;
return (div);
}
// ]]>
</script>

Regards!

ajfmrf
02-14-2013, 08:57 PM
What you posted is not html it is javascript.

I did see the cursor thing working fine and sourced the page to see what was missing.(personally that is annoying to me and I don't know why someone would want it.But that is my opinion only-lol)

But I moved the location of the cursor script and this is what I got using Firefox 18.0.2
http://www.web-user.info/test/cursor/cursor.html

balki
02-15-2013, 01:52 PM
I agree about the effect, but it is intended for young children, students, and it is interesting for them.
The strangest thing is that the same script I'm featured before on another page of the site and work there - http://www.souhssz.com/tjestova/jefjekt-srchitsa
I tried the script and it works on other sites. Why does not on my site? :confused:

ajfmrf
02-15-2013, 05:18 PM
I don't understand.It is working on the page I made and the menu is clearly visible on the left side.

Is this not what you want?The script for the cursor is working as well as the menu being there......

balki
02-15-2013, 06:16 PM
I gave two links, both with same script:
http://www.souhssz.com/tjestova/question - no menu
http://www.souhssz.com/tjestova/jefjekt-srchitsa - with menu
I see that on your website it works, but on first link my menu missing :confused:

ajfmrf
02-15-2013, 11:55 PM
All you need to do is move the javascript for the hearts cursor out of the widget div and put it in the head of the page like I did here:

http://www.web-user.info/test/cursor/question.html


<div class="rbcWidgetArea" style="text-align: center;"><script type="text/javascript" src="http://www.souhssz.setra.icnhost.net/p/heart.js"></div>
</div><!-- / id="mainZone" class="colA" -->

I moved the highlighted line to the head section(source my page to see) and left the div empty.
<!-- / CENTER ZONE ~ MAIN -->

balki
02-16-2013, 09:42 AM
Well, that explains the problem. I have no rights to write in the head part.
The main menu disappears when I use an external host.
On the webpage http://www.souhssz.com/tjestova/jefjekt-srchitsa/ I put the whole script from the first post in the topic.
Now, when I use the same technique, cursor effect does not work on different page - http://www.souhssz.com/tjestova/question/ and I don't know why?

ajfmrf
02-16-2013, 10:39 PM
I did not see the cursor's 'hearts.js' file when I sourced your page.

Did you forget to add it to the different page?

After I posted I went and checked it out.You did indeed forget the cursor script in the "different" page.I uploaded the different page and when I added the hearts.js script to it it worked fine.

http://www.web-user.info/test/cursor/different.html

balki
02-17-2013, 10:45 AM
It is difficult to understand each other :)
Currently on my two pages I dont use http://www.souhssz.setra.icnhost.net/p/heart.js I use the script from the first post which I set with embed option. The mystery is why on a first page script is executed, but on other is not running?

Regards!

ajfmrf
02-17-2013, 05:22 PM
Now you are confusing me.

Post each page and what is wrong with either page.If it is okay note the page as being ok but also note which one is not working like you want.We will need to do this t see what is what

balki
02-17-2013, 08:01 PM
When I used the script posted on an external host main menu disappeared. So I embed in a web page script in the form from first post on this topic.
Currently I have two pages with a script placed in the same way:
- The first (http://www.souhssz.com/tjestova/jefjekt-srchitsa/) was made last year and there is a visible effect.
- I made a second (http://www.souhssz.com/tjestova/question/) on 02-14-2013, but the effect is not visible.
Excuse my bad English. Thanks for trying to help me :)

ajfmrf
02-17-2013, 11:56 PM
Okay,I don't know why you have decided to put the script in the html file instead of using the link to the file as you had before.(I am refering to this file which you originally used-
<script type="text/javascript" src="http://www.souhssz.setra.icnhost.net/p/heart.js">)

The red file is the easy way to go.Sometimes when you cut and paste a javascript file a break in the script can somehow prevent it from working.I usually have a hard time to find the problem.

You have the easy way to go to fix it.instead of using that whole script written out in your file use the red part in the header and it works fine.I took your file and put it in the head and left the other script in there knowing it does not work.

Here is the working file with that script in the head but without it written in the file the long way.http://www.web-user.info/test/cursor/question2.html

I hope I did not confuse you more?

balki
02-18-2013, 04:30 PM
But when I use this way (<script type="text/javascript" src="http://www.souhssz.setra.icnhost.net/p/heart.js">) my main menu disappears, this was the initial problem.
Furthermore, I explained that I have not access to the <head> part and that only on this site the script doesn't work correctly.

ajfmrf
02-18-2013, 05:17 PM
So you can't edit the page?

Beverleyh
02-18-2013, 06:07 PM
I hope you don't mind me asking balki, but are you using a public 3rd party website service?

Or has your web developer provided an interface with very limited access (can you ask them to maybe make alterations on your behalf)?

It sounds like you don't have full access to your entire website (pages or structure) which will make some customisations virtually impossible.

If you can clarify to what extent you do and don't have access, it would help us out a lot.

balki
02-18-2013, 07:43 PM
Yes Beverleyh, you're right about everything :) I using a public 3rd party website service. I have an option "embed code" and access to CSS, but no option for more rights. With "embed code" button I'm embedding a different functions requiring placing in <head> part, so I have control, although not a full.
Riddle in the case is that the same script, set in the same way, places of the two different pages works only on one page published last year.

Beverleyh
02-19-2013, 06:27 AM
Well, that explains the problem. I have no rights to write in the head part.

Furthermore, I explained that I have not access to the <head> part

With "embed code" button I'm embedding a different functions requiring placing in <head> part, so I have control, although not a full.This is very confusing. You first said that you can't edit the head section (twice) but then you said you can?

As I said in my previous post, if you cant edit the head section, you wont be able to do some customisations. I believe the solution has already been provided, but if you are unable to use it, then you're pretty stuck. Maybe this is a time to consider moving to another service or making a website yourself (you can download free templates to help with design or a fast turn around) on a web host that will allow you full and complete control of all your code.

I'm sorry if that's not the news you want to hear but I imagine that the majority of active members here are more used to working on and developing websites where we have full backend access, with minimal restrictions, so it is very difficult to offer help when the other party uses a heavily restricted service provider.

balki
02-19-2013, 03:11 PM
Let me explain. I can't see the HTML document in its full form, eg:

<html>
<head>
...
</headl>
<body>
...
</body>
</html>
but I have a button whose content is interpreted as being in <head> part.
I have implemented features, which can work only in <head> placement, but as I wrote above same script I realized (http://www.souhssz.com/tjestova/jefjekt-srchitsa/) on one page and wondering, why not working on another (http://www.souhssz.com/tjestova/question/).
:rolleyes:

ajfmrf
02-19-2013, 05:30 PM
Take this page http://www.souhssz.com/tjestova/question/ and remove the script you put in it.There is something wrong with it(spaces or something else)

Then go to the other page http://www.souhssz.com/tjestova/jefjekt-srchitsa/ and copy the script you inserted.Then go back to the 'question page and paste it in where you had it in the first page.

Hopefully there will be no issue and it will work.

The only reason it does not work on that page is that something is wrong with the script and it is not firing(working).It should work but I did not look to see if there is part missing or messed up.

balki
02-19-2013, 07:53 PM
I know that placing script in Notepad change the type of quotes and "breaks" script. I have not made that mistake.
Now I pay attention to continuous loading of the page and will ask support if the problem is not with them.
Thanks for the help! I would write here if I get news.

balki
02-22-2013, 04:44 PM
I received a response to my support request:


The external widgets sometimes cause problems - they can work correctly on one page but not on another one. It also looks like you have edited the CSS of the template. This can be cause for different issues as well.

I changed the template only for images so I don't expect to get a solution for issue.