Forum Moderators: open
var clickCount=0;
document.onClick='clickCount++';
if(clickCount==4){parent.border.location='htt:/ww.e_x_a_m_p.com/home/home-border-top-pissed1.php'};
if(clickCount==8){parent.border.location='htt:/ww.e_x_a_m_p.com/home/home-border-top-pissed2.php'};
if(clickCount==12){parent.border.location='htt:/ww.e_x_a_m_p.com/home/home-border-top-pissed3.php'};
if(clickCount==16){parent.border.location='htt:/ww.e_x_a_m_p.com/home/home-border-top-pissed4.php'};
if(clickCount==20){parent.border.location='htt:/ww.e_x_a_m_p.com/home/home-border-top-pissed5.php'};
if(clickCount==22){clickCount=0}
Here is how the code worked fine...
<script type="text/javascript">
<!--
var clickCount=0;
//-->
</script>
</head>
<body onClick="clickCount++;if(clickCount==4){parent.border.location='htt:/ww.e_x_a_m_p .com/home/home-border-top-pissed1.php'};if(clickCount==8){parent.border.location='htt:/ww.e_x_a_m_p .com/home/home-border-top-pissed2.php'};if(clickCount==12){parent.border.location='htt:/ww.e_x_a_m_p .com/home/home-border-top-pissed3.php'};if(clickCount==16){parent.border.location='htt:/ww.e_x_a_m_p .com/home/home-border-top-pissed4.php'};if(clickCount==20){parent.border.location='htt:/ww.e_x_a_m_p .com/home/home-border-top-pissed5.php'};if(clickCount==22){clickCount=0}">
document.onClick='clickCount++';
You need to assign a function to the event.
Right know, you are just assigning a string : "clickCount++"
(( to a custom property, onClick ))
[pre]document.onclick=function()
{
clickCount++
if(clickCount ..etc)
...etc
};[/pre] Also email notification of replies isn't working
I try my hardest to please, but I can't solve everything :)
var clickCount = 0;
var clickSpacing = 4;
var clickCycle = 22;document.onclick = function()
{
clickCount = ++clickCount % clickCycle // if 22, return to zero
if(clickCount &&!(clickCount % clickSpacing)) // if clickCount is non-zero multiple of clickSpacing
parent.border.location
='htt:/ww.e_x_a_m_p.com/home/home-border-top-pissed'
+(clickCount/ clickSpacing)+'.php';
}
document.onclick=function()
{
clickCount++
if(clickCount==4){parent.border.location='http://www.?.com/home/home-border-top-pissed1.php'};
if(clickCount==8){parent.border.location='http://www.?.com/home/home-border-top-pissed2.php'};
if(clickCount==12){parent.border.location='http://www.?.com/home/home-border-top-pissed3.php'};
if(clickCount==16){parent.border.location='http://www.?.com/home/home-border-top-pissed4.php'};
if(clickCount==20){parent.border.location='http://www.?.com/home/home-border-top-pissed5.php'};
if(clickCount==22){clickCount=0}
... and it didn't work.
The second script only allows me to specify one url? So I tried modding it as so. Also how do I set the number for each click count to trigger? Whats % do?
var clickCount = 0;
var clickSpacing = 4;
var clickCycle = 22;document.onclick = function()
{
clickCount = ++clickCount % clickCycle // if 22, return to zero
if(clickCount &&!(clickCount % clickSpacing)) // if clickCount is non-zero multiple of clickSpacing
parent.border.location ='http://www.?.com/home/home-border-top-pissed1.php' +(clickCount/ clickSpacing)+'.php';else(clickCount &&!(clickCount % clickSpacing)) // if clickCount is non-zero multiple of clickSpacing
parent.border.location ='http://www.?.com/home/home-border-top-pissed2.php' +(clickCount/ clickSpacing)+'.php';else(clickCount &&!(clickCount % clickSpacing)) // if clickCount is non-zero multiple of clickSpacing
parent.border.location ='http://www.?.com/home/home-border-top-pissed3.php' +(clickCount/ clickSpacing)+'.php';else(clickCount &&!(clickCount % clickSpacing)) // if clickCount is non-zero multiple of clickSpacing
parent.border.location ='http://www.?.com/home/home-border-top-pissed4.php' +(clickCount/ clickSpacing)+'.php';else(clickCount &&!(clickCount % clickSpacing)) // if clickCount is non-zero multiple of clickSpacing
parent.border.location ='http://www.?.com/home/home-border-top-pissed5.php' +(clickCount/ clickSpacing)+'.php';else(clickCount &&!(clickCount % clickSpacing)) // if clickCount is non-zero multiple of clickSpacing
parent.border.location ='http://www.?.com/home/home-border-top-pissed6.php' +(clickCount/ clickSpacing)+'.php';
}
Ok so a % basically divides the combined numbers and spits out the nearest round number?
If that's the case I'm not sure what the goal is then?
Thanks for the help guys! If we get this working you can piss off my website and it'll still validate as XHTML 1.1 strict! I got my frame target to work this past weekend and I gotta thank the folks at this forum for it! :-)
Ok so a % basically divides the combined numbers and spits out the nearest round number?
If that's the case I'm not sure what the goal is then?
Pretty much (the number after the % should be an integer). The situation gets more complicated where any negative numbers are concerned, and this is where the modulus operator diverges from the accepted behaviour of modulus in mathematics.
I'm more used to a modulus representing a cyclic mapping onto a restricted set of integers.
When you're a kid, it's introduced as "clock arithmetic". The hour hand on a clock goes round endlessly, but it's resticted to a set of integers.
In our case, to get the effect:
[blue]if(++clickCount > 12) clickCount = 0;[/blue] we use:
[blue]clickCount = ++clickCount % 22;[/blue] because:
[blue]// n=21
n % 22 -> 21// n=22
n % 22 -> 0[/blue]
It has only saved a few characters, but it's a more flexible form, and I'd go as far as saying that is the used as standard in a any programming language that has the operator.
... and it didn't work.
Odd. There's been a bit of this recently.
Perhaps there's some copy and paste problem.
..oh hang on..
If you are using an XHTML strict doctype, that may have an effect on what the browser considers clickable.
Rambo..?
The second script only allows me to specify one url
The URLs in your example only differ by the integer on the end {1,2,3,..}. So it seemed a wasted opportunity not to do it like that. If the URLs actually differ in some other way too, then your original form will have to do. Using an array structure would be more succint, but..who cares?
This is a very simple scripting process, so I can't see a reason for any of the versions not to work, apart from
- doctype issues
- the way that the child frame's window object is referenced
In what way is it not working?
- Are clicks activating the function? (stick in an alert)
If you're asking me about XHTML, you've probably got the wrong furry creature. I've done reading on the subject, but tend to consider XHTML more suitable for intranet projects than those for the wild and wooley web. Support for the X just doesn't seem quite there yet (that is not to say XML isn't essentially useful for data and web services).
I don't recall encountering anything that said XHTML put any restrictions on what was clickable. Even if it did, I'd question whether browsers would be so strict in its implementation. We tribbles aren't particularly good at strict. I'd always heard it was you English lads that fancied the discipline thing.
If the URLs only differ by the index that appears just before the file extension, then the application of a little arimetic leaves us only having to hard-code the constant part of the URLs once.
If the URLs are more different than that, then they could be put into an array, then (again) a little arithmetic is applied to dereference them.
The benefit of all this is that the 'click spacing' - how many clicks between each new URL - can be changed with a single value. Otherwise we'd have to go through and change all the numbers
[4,8,12,..]-->[5,10,15,..]. Also, for lovers of code beauty, the URLs can be kept together in a list. I agree that switch structures can be neater, if the only other option is an
if..else Rambo, I was just wondering whether one is supposed to (scriptwise) apply the event handler to the BODY or HTML element instead, in this strict scenario.
We could just get round this by applying an HTML event handler to the BODY tag (as before), and give that anonymous function a name. We still don't know the actual details of the problem yet though.
I appreciate your faith in my acumen, Mr. Marx, and would just like to take this opportunity to remind our readers of my motto:
"Rambo Tribble: If he doesn't know the answer, he'll make something up."
The presentation of some dense, apparently optimised, code renders me beyond suspicion, at least while it's being worked out. Fortunately, this is, more often than not, a great deal longer than it takes for me to write it.
(function(){var doo = this[(get[dweeb()]¦¦'jala jala')(n%42)]})('hello') ::Rambo::
I'd always heard it was you English lads that fancied the discipline thing.
Cheeky. I have only just noticed that one.
Here's what I did for a bit of strict punishment:
1. Copied the frameset from JAB's site.
The document at
/home/nm/ 2. Also copied the document sourced in the frame named 'border'.
Otherwise, cross-domain restrictions would prevent my script test from working.
- changed the extension to
.htm . 3. Copied a page from a well-known website, and purveyor of all things standards.
I then gutted the page, leaving only those declarations required to keep the the document goosestepping smartly in XHTML fashion.
This last page was used as the 'clicking' page, and I put it into the main frame of the set, and linked the script posted at #4 (+ a couple of additions for display).
----
Everything else was left in place.
Since all the necessary URLs in the docs are absolute, everything else was being sourced from JAB's server.
----
As I hoped, it all works fine (IE & FF). Playing the soundbites as required.
(and, I don't know why, but I don't get cross-domain problems after the first location change ...?)
----
Anyway, I have put the thing at the usual place. This does, I realize, involve some dirty hotlinking on a temporary basis (all in a good cause).
The URL is being stickied.