Friday 7 October 2011

What does the "#" mean in this java script code and why am I getting a # symbol in my title of my webpage?

function MM_preloadImages() { //v3.0

var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();

var i,j=d.MM_p.length,a=MM_preloadImages.arg鈥?for(i=0; i%26lt;a.length; i++)

if (a[i].indexOf(%26quot;#%26quot;)!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}



I am not sure what the # is in this java script code. It is colored blue in dreamweaver and I was wondering if I need to change it - like it affects the title or something somewhere in the page.



I also have a funky problem in my webpage title - the # symbol appears at the end of whatever I type and I dont know how to get rid of it. This is the index page of a website and the page includes a couple of cf includes that have navigation browsers in them. That is it- no content yet.



How do I fix that problem?What does the %26quot;#%26quot; mean in this java script code and why am I getting a # symbol in my title of my webpage?The # is related to the HTML href property.



Example:



%26lt;a href=%26quot;#section1%26quot;%26gt;Jump to section 1%26lt;/a%26gt;



is an anchor that will jump to this anchor on the page:



%26lt;a name=%26quot;section1%26quot;%26gt;Section 1%26lt;/a%26gt;



When you click on the first anchor, the page will then jump to the position of the named anchor.



So this is really a link to an element within the same page rather than a jump to another page.



That's exactly what the javascript is attempting to ignore - it only wants to preload images with a src that points to a direct URL. So if (a[i].indexOf(%26quot;#%26quot;)!=0) is making sure

that arguments to the function should be URLS and not relative jumps within this page (in which case you would have a # at position 0 like in the example above).





Your other problem can be demonstrated by looking at



%26lt;a href=#%26gt;Click and watch the title%26lt;/a%26gt;



When you click on this, the # gets appended to the URL of the current web page so you will see an extra # next to the URL in the address bar. It's the same effect as



%26lt;a href=%26quot;anotherURL#%26quot;%26gt;Another page with #%26lt;/a%26gt;



because you can also jump to a position in another web page like this.



Hope this helps
What does the %26quot;#%26quot; mean in this java script code and why am I getting a # symbol in my title of my webpage?
I think it means number. IDK really
What does the %26quot;#%26quot; mean in this java script code and why am I getting a # symbol in my title of my webpage?
The hash/pound symbol has no special meaning native to JavaScript. In this context, it is being used to mark a condition that was designed into the data-model that your preload function expects. The programmer and data-designer agreed to that having the hash symbol in the first position of certain data elements would indicate a particular state to the function. In this case, if the # is NOTt the first character in a string item, then the program believes it to be the URL of an image file. This implies the use of a mixed datastructure (MM_preload.... - whatever that name refers to) of some sort with special characters used to mark particular types of data items.



Pre-loading images is a standard practice. It improves the user experience by ensuring that all images that will be used are actually available before they are referenced by a function.



I don't know what you mean by %26quot;the # symbol appears at the end of whatever I type.%26quot;