Java script behaves different dependent upon server
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- Java script behaves different dependent upon serve...
Java script behaves different dependent upon server
10-02-2014 11:11 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
The code in question is...
Quote //
// Scan the style sheet rules to find the item who's selector text is the same
// as the prompt box style selector [navPromptStyleName] & [minifoodStyleName]
//
while (document.styleSheets(0).rules.item(navPromptStyleIndx).selectorText != navPromptStyleName){
navPromptStyleIndx = navPromptStyleIndx + 1
}
while (document.styleSheets(0).rules.item(minifoodStyleIndx).selectorText != minifoodStyleName){
minifoodStyleIndx = minifoodStyleIndx + 1
}
Setting aside any discussions on is this is the right way to do what I want to do across all browser platforms, this works as expected in IE when the server is IIS - but when delivered from apache the line highlighted in red gives the error "Function Expected".
Has anyone seen anything similar to this please?
Note, due to a recent major failure of my PC (no current back up >:() my local (IIS) web content is a clone of what is on the production platform, so it is not possible for me to have something local which is not on the server.

In another browser tab, login into the Plusnet user portal BEFORE clicking the fault & ticket links
Superusers are not staff, but they do have a direct line of communication into the business in order to raise issues, concerns and feedback from the community.
If this post helped, please click the Thumbs Up and if it fixed your issue, please click the This fixed my problem green button below.
Re: Java script behaves different dependent upon server
11-02-2014 12:05 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Also, while it's aparrently failling in IE, does it also fail in Firefox or Chrome?
Another thing that would help determine where the problem is happening is to split the while condition over multiple lines.
e.g.
var stylesheet = document.stylesheets(0); //does it error here?
while (navPromptIndx < stylesheet.rules.length) {
var item = stylesheet.rules.item(navPromptIndx); //or here?
// var item = stylesheet.rules[napPromptIndx]; //and does this work?
if (item.selectorText == navPromptStyleName) break;
++navPromptStyleIndx;
}
(btw, this isn't tested, and I've been drinking ;))
Re: Java script behaves different dependent upon server
11-02-2014 8:27 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Quote from: kmilburn If it works locally, but doesn't after uploading, one candidate would be line endings. Check whether the files are transferred in binary or ascii mode.
(btw, this isn't tested, and I've been drinking ;))
Kmilburn,
Thank you for the input, especially the idea of splitting up the code.
I too had wondered about the line endings, but had dismissed that as the code the works had been down loaded from the live server after the local HDD crash. Will take a look at the code again later today / tomorrow - have SWMBO tasks today!
Drinking? I do hope that was quality real ale? Ideally from a local brewery?
Cheers,
Kevin
In another browser tab, login into the Plusnet user portal BEFORE clicking the fault & ticket links
Superusers are not staff, but they do have a direct line of communication into the business in order to raise issues, concerns and feedback from the community.
If this post helped, please click the Thumbs Up and if it fixed your issue, please click the This fixed my problem green button below.
Re: Java script behaves different dependent upon server
18-02-2014 3:17 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Issue 1
The web servers appear to be 'pre-processing' the style sheet selectors. IIS capitalises HTML element selectors where as the PN platform sets them to lower case.
Quote from: STYLESHEET .NavBar A span
{ ... }
Quote from: IIS .NavBar A SPAN
{ ... }
Quote from: PN .NavBar a span
{ ... }
My code was looking for a style selector matching ".NavBar A SPAN" so that explains one source of code functionality difference / failure when served from the PN server. This is easily fixed by forcing an uppercase or lowercase comparison.
Issue 2
The "Function Expected" error arises from the incorrect (?) syntax for indexing collections - "(n)" vs. "
Quote from: Code var CSSsheet = document.styleSheets(0);
Quote from: Change var CSSsheet = document.styleSheets[ 0 ]; //ignore spaces inserted to avoid BB controls issues
I guess that I had better learn to tell the difference between "()" and "[]" - given that both work when served from IIS - the code can be changed to the latter!
Issue 3
Code modifying style sheet properties which works when served from the IIS server appears simply not to function when served from the PN server.
Quote var Oldtop = CSSsheet.rules.item(navPromptStyleIndx).style.top
CSSsheet.rules.item(navPromptStyleIndx).style.top = parseInt(NavSpacer.offsetTop) ;
alert ("Server:\t"+document.location+"\nBefore:\t"+Oldtop+"\nRequired:\t"+NavSpacer.offsetTop+"\nAfter:\t"+CSSsheet.rules.item(navPromptStyleIndx).style.top)
This totally confuses me!
Edit: Screen captures omitted when first writing this have been added.
Has anyone seen the like of these issues (characteristics) before? I cannot understand how CLIENT side code changes its functionality depending on the server used to deliver the code. It is apparent that something is altering the character and functionality of the code delivered to the client. Any insight / suggestions would be most welcome.
In another browser tab, login into the Plusnet user portal BEFORE clicking the fault & ticket links
Superusers are not staff, but they do have a direct line of communication into the business in order to raise issues, concerns and feedback from the community.
If this post helped, please click the Thumbs Up and if it fixed your issue, please click the This fixed my problem green button below.
Re: Java script behaves different dependent upon server
18-02-2014 3:36 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Check and see if there is anything like that running on the host.
Ex-Broadband Service Manager
Re: Java script behaves different dependent upon server
18-02-2014 4:06 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
That is an interesting idea in respect of issue 1... the host which is giving me the issues is PN's homepage server... what such code does it run please?
Thanks,
Kevin
In another browser tab, login into the Plusnet user portal BEFORE clicking the fault & ticket links
Superusers are not staff, but they do have a direct line of communication into the business in order to raise issues, concerns and feedback from the community.
If this post helped, please click the Thumbs Up and if it fixed your issue, please click the This fixed my problem green button below.
Re: Java script behaves different dependent upon server
18-02-2014 4:07 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Ex-Broadband Service Manager
Re: Java script behaves different dependent upon server
18-02-2014 4:24 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Yes bog-standard-not-now-offered home pages. HTML / CSS / JS files are hosted on the PN server, however when they 'hit' the client they function differently. Looks like both Apache and IIS do something with the CSS files, though that does not explain issues 2 & 3.
1 & 2 can be coded around (I have already done so) but issue 3 remains. Note addition of the ALERT box screen grabs.
Cheers,
Kevin
In another browser tab, login into the Plusnet user portal BEFORE clicking the fault & ticket links
Superusers are not staff, but they do have a direct line of communication into the business in order to raise issues, concerns and feedback from the community.
If this post helped, please click the Thumbs Up and if it fixed your issue, please click the This fixed my problem green button below.
Re: Java script behaves different dependent upon server
18-02-2014 4:34 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Re: Java script behaves different dependent upon server
18-02-2014 4:34 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Ex-Broadband Service Manager
Re: Java script behaves different dependent upon server
18-02-2014 4:50 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Err No, I had not - I do not have ready access to other browsers - frankly I trust them less than IE, though first I was looking for consistent success / fail with the one browser platform. Whatever might be thought to be "non standard" with IE (please show me a browser which is fully 'standard' in all respects) it ought to get the same things right / wrong with the same 'inputs' irrespective of the host platform.
I have just tested it with Safari on an iPad and issue 3 fails consistently across both platforms, but given that it has no diagnostic console, I cannot discern why! it is also interesting is the fact that on the iPad, I'm not getting the images loaded - need to take a closer look at that one!
@Kelly,
I believe I have cleared out the caches properly

Cheers,
Kevin
In another browser tab, login into the Plusnet user portal BEFORE clicking the fault & ticket links
Superusers are not staff, but they do have a direct line of communication into the business in order to raise issues, concerns and feedback from the community.
If this post helped, please click the Thumbs Up and if it fixed your issue, please click the This fixed my problem green button below.
Re: Java script behaves different dependent upon server
18-02-2014 8:38 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Another thing thing to look at, have you checked the web/javascript console to determine if any errors are being reported?
Trying with a Chrome or Firefox will help determine which side might be causing the problem, and both provide diagnostic tools.
One potential problem with the IPad, which you may also see in other browsers, come from a difference in rule handling.
e.g. This is the old method of accessing rules
CSSsheet.rules.item(navPromptStyleIndx).style.top
However, you'd be better off with the following (as indicated by MSDN and Mozilla)
CSSsheet.cssRules.item(navPromptStyleIndx).style.top
or
CSSsheet.cssRules[navPromptStyleIndx].style.top
And another problem with compliant browsers:
The CSSStyleRule interface represents a style rule. The style attribute returns the CSSStyleDeclaration object for the rule, which is Read only.
In the time it's taken me to write this, I think I've had an epiphany (don't worry, it didn't hurt ;))
I think there is an interaction going on between IIS and IE which is causing IE to drop into 'Quirks Mode'. As a result, it drops back to older behaviour where things that shouldn't work still do.
Meanwhile, Apache isn't causing the same effect, resulting in IE being in 'Strict Mode', with side effects like an attribute specified as read-only, actually being read-only.
You should find both Chrome and Firefox will also fail on both platforms for the same reason, which you've already seen with your iPad.
Re: Java script behaves different dependent upon server
20-02-2014 6:07 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Quote from: Townman Setting aside any discussions on is this is the right way to do what I want to do across all browser platforms
Still a bit ahead of its time for cross-browser support.
What is it you want to do?
Gabe
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- Java script behaves different dependent upon serve...