473,666 Members | 2,728 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cuffs - code and effect comment?

<URL:http://www.merlyn.demo n.co.uk/js-index.htm>, and js-dates.htm, and
some Easter pages, now include <BODY onload="Cuffs() ">.

function Cuffs() { var ThisPage, ThisSite, J, DLJ, HREF
ThisPage = location.href.r eplace(/#.*/, "")
ThisSite = location.protoc ol + "//" + location.hostna me + "/"
for (J in document.links) {
DLJ = document.links[J] ; HREF = DLJ.href
if (!HREF) continue // why an undefined ?
HREF = String(HREF)
if (HREF.indexOf(T hisPage) == 0) DLJ.title = "." ;
else if (HREF.indexOf(T hisSite) == 0) DLJ.title = "+" ;
else if (HREF.indexOf(" http://") == 0) DLJ.title = "#" ;
else DLJ.title = "*" } }

Comment on the code or its effect?

Why does HREF = String(HREF) seem needed?

Only tested in XP sp2 IE6 & FF 2.0.0.3.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 IE 6
news:comp.lang. javascript FAQ <URL:http://www.jibbering.c om/faq/index.html>.
<URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
May 24 '07 #1
4 1341
On May 24, 2:46 pm, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
<URL:http://www.merlyn.demo n.co.uk/js-index.htm>, and js-dates.htm, and
some Easter pages, now include <BODY onload="Cuffs() ">.

function Cuffs() { var ThisPage, ThisSite, J, DLJ, HREF
ThisPage = location.href.r eplace(/#.*/, "")
ThisSite = location.protoc ol + "//" + location.hostna me + "/"
for (J in document.links) {
DLJ = document.links[J] ; HREF = DLJ.href
if (!HREF) continue // why an undefined ?
HREF = String(HREF)
if (HREF.indexOf(T hisPage) == 0) DLJ.title = "." ;
else if (HREF.indexOf(T hisSite) == 0) DLJ.title = "+" ;
else if (HREF.indexOf(" http://") == 0) DLJ.title = "#" ;
else DLJ.title = "*" } }

Comment on the code or its effect?

Why does HREF = String(HREF) seem needed?
That would be due to the fact that your iteration construct causes all
properties of the document.links object to be included, many of which
you do not wish to access. Try

for ( J = 0; J < document.links. length; ++J ) {
...
}
--
../rh
May 25 '07 #2
On May 24, 3:46 pm, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
function Cuffs() { var ThisPage, ThisSite, J, DLJ, HREF
ThisPage = location.href.r eplace(/#.*/, "")
ThisSite = location.protoc ol + "//" + location.hostna me + "/"
for (J in document.links) {
DLJ = document.links[J] HREF = DLJ.href
if (!HREF) continue // why an undefined ?
HREF = String(HREF)
if (HREF.indexOf(T hisPage) == 0) DLJ.title = "." ;
else if (HREF.indexOf(T hisSite) == 0) DLJ.title = "+" ;
else if (HREF.indexOf(" http://") == 0) DLJ.title = "#" ;
else DLJ.title = "*" } }

Comment on the code or its effect?

Why does HREF = String(HREF) seem needed?
function Cuffs() {
var ThisPage,ThisSi te,J,DLJ,HREF;
var l=location,link s=document.link s;
ThisPage = l.protocol+'//'+l.host+l.path name+l.search
ThisSite = l.protocol+"//"+location.host name+'/';
for(J=0;J<links .length;J++){
DLJ = links[J];
HREF = DLJ.href;
if (HREF.indexOf(T hisPage) == 0)
DLJ.title = ".";
else if (HREF.indexOf(T hisSite) == -1)
DLJ.title = "+";
else if (HREF.indexOf(" http://") == -1)
DLJ.title = "#";
else DLJ.title = "*"
}
}
May 25 '07 #3
In comp.lang.javas cript message <11************ **********@q19g 2000prn.go
oglegroups.com> , Thu, 24 May 2007 17:55:06, ro********@gmai l.com posted:
>On May 24, 2:46 pm, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
><URL:http://www.merlyn.demo n.co.uk/js-index.htm>, and js-dates.htm, and
some Easter pages, now include <BODY onload="Cuffs() ">.
>Why does HREF = String(HREF) seem needed?

That would be due to the fact that your iteration construct causes all
properties of the document.links object to be included, many of which
you do not wish to access. Try

for ( J = 0; J < document.links. length; ++J ) {
I've been able to return to this code (which is now used in most of
those of my pages which use the corresponding Include file).

Understood; tested; OK; thanks.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demo n.co.uk/- FAQqish topics, acronyms & links;
Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Jun 6 '07 #4
On Jun 6, 2:34 pm, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
In comp.lang.javas cript message <1180054506.240 417.286...@q19g 2000prn.go
oglegroups.com> , Thu, 24 May 2007 17:55:06, ron.h.h...@gmai l.com posted:
On May 24, 2:46 pm, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
<URL:http://www.merlyn.demo n.co.uk/js-index.htm>, and js-dates.htm, and
some Easter pages, now include <BODY onload="Cuffs() ">.
Why does HREF = String(HREF) seem needed?
That would be due to the fact that your iteration construct causes all
properties of the document.links object to be included, many of which
you do not wish to access. Try
for ( J = 0; J < document.links. length; ++J ) {

I've been able to return to this code (which is now used in most of
those of my pages which use the corresponding Include file).

Understood; tested; OK; thanks.
All's swell that mends well. You're welcome!

--
../rh

Jun 7 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
5927
by: Hung Jung Lu | last post by:
Hi, I know people have talked about it before, but I am still really confused from reading the old messages. When I talk about code blocks, I am not talking about Lisp/Ruby/Perl, so I am not making comparisons. If you have a file, in Python you could do:
21
6221
by: AnnMarie | last post by:
<script language="JavaScript" type="text/javascript"> <!-- function validate(theForm) { var validity = true; // assume valid if(frmComments.name.value=='' && validity == true) { alert('Your full name is required. Please enter your full name!'); validity = false; frmComments.name.focus();
15
2328
by: Matt Kruse | last post by:
I am far from a PHP expert, and I've been struggling to create a function which will take a javascript .js file and "compact" it as much as possible. Meaning, remove all comments and unnecessary whitespace. "Obfuscation" is not necessary. Obviously, the compacted javascript should run identically to the original javascript. Can anyone point me to an existing function that does this? Thanks!
26
2875
by: Martin Jørgensen | last post by:
Hi, I don't understand these errors I get: g++ Persort.cpp Persort.cpp: In function 'int main()': Persort.cpp:43: error: name lookup of 'j' changed for new ISO 'for' scoping Persort.cpp:37: error: using obsolete binding at 'j'
14
7027
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that sql server resides on is not reachable. The error is different depending on the connection string that I use. If I use the following connection string: "server=192.1.1.1; Initial Catalog=master; uid=The_User; password=The_Password; Connect...
16
2794
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and efficient navigating within Visual Studio 2005. Let's say your project (or solution) has dozens of forms and hundreds or even thousands of routines. Two Questions: 1) BUILT-IN to Visual Studio 2005. What ideas do you have to quickly
9
3491
by: scriptguru | last post by:
I've found some funny pieces of code in one project... I don't know: to laught or to cry =) function toHex(decimal) { switch(decimal) { case 10: return "A"; case 11: return "B"; case 12:
26
4092
by: vlsidesign | last post by:
I am a newbie and going through "The C programming language" by Kernighan & Richie on my own time (I'm not a programmer but I want to learn because it can save me time in my normal job, and it is kind of fun). As I go through the book, I seek to do all the exercises because they are very useful, and good, but it seems like I am just stumbling through somewhat. In particular, I don't really know how to think about "catching errors", or how...
14
3869
by: daskumardilip | last post by:
how to remove comment from c source code.
0
8438
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8348
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8863
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7376
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2765
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2004
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.