开发者

"Uncaught TypeError: Property 'addListGroup' of object [object DOMWindow] is not a function"

开发者 https://www.devze.com 2023-03-21 08:36 出处:网络
Asked this the other day but didn\'t get a reply. I was to create EXACTLY THIS chained selection example (demo10):

Asked this the other day but didn't get a reply. I was to create EXACTLY THIS chained selection example (demo10):

http://www.yxscripts.com/cs/cs.zip

It all looks okay but if you open this in Google Chrome, when you select Honda from the first box - the program fails. I press 'ctrl shift J' to try and find out what the issue is and it tells me:

"Uncaught TypeError: Property 'addListGroup' of object [object DOMWindow] is not a function"

Any clues as 开发者_Python百科to what I can do to solve this? The error is within 'content_honda.js':

addListGroup("content_honda.html", "Honda");

addOption("Honda", "--- Honda vehicles ---", "");
addList("Honda", "Cars (on-the-fly)", "car", "content_honda_sub.html");
addList("Honda", "SUVs/Van", "suv", "Honda-SUVs/Van", 1);

addOption("Honda-SUVs/Van", "--- Honda SUVs/Van ---", "");
addOption("Honda-SUVs/Van", "CR-V", "CR-V");
addOption("Honda-SUVs/Van", "Pilot", "Pilot");
addOption("Honda-SUVs/Van", "Odyssey", "Odyssey", 1);

updateSubList("vehicles", "content_honda.html");


You're calling a function that hasn't been defined. You're going to want to look into prerequisites for this sample (check the yxscripts.com site) or otherwise locate the necessary included scripts. I've never seen addListGroup as a standard DOM function.


It's a cross-domain security issue. It is broken loading the demo10.html as a local file in the browser, but if you host the demos using a webserver (I used Jetty) then it works as expected.

Running as a local file I get the following error in the Chrome console:

Unsafe JavaScript attempt to access frame with URL file:///C:/Users/xxx/Desktop/so/cs/examples/demo10.html from frame with URL file:///C:/Users/xxx/Desktop/so/cs/examples/content_honda.html. Domains, protocols and ports must match.

That said, I totally agree with @Pointy in that this library is pretty horrific. Personally, I would start again and build something yourself. It's a nice problem to solve and a good learning experience. You could even take advantage of some of the existing JavaScript libraries to minimise any cross-browser issues.

0

精彩评论

暂无评论...
验证码 换一张
取 消