Jump to content

Scripting error


Buoka
 Share

Recommended Posts

I have tried to use the following with the javascript out in a .js file and with it in the <head> but in either case all I get is a call for debug.Can someone tell me where my code is wrong.The code calling the function is:

<input class="accs" type="image" src="Images/SpAc_PumpSub.jpg" alt="Nutool Submersible Pump" title="Nutool Submersible Pump" value="SpAc01" onclick="SpAc('Accs/SpAc01.html').js" />

or

<input class="accs" type="image" src="Images/SpAc_PumpSub.jpg" alt="Nutool Submersible Pump" title="Nutool Submersible Pump" value="SpAc01" onclick="SpAc('Accs/SpAc01.html')" />

The script in SpAc.js is:

function SpAc(addr) {window.open(addr,'Spa Accessory','width=675,height=260');}

The same code - unchanged completely - has been tried in the head thus:

function SpAc(addr) {window.open(addr,'Spa Accessory','width=675,height=260');  }  </head>

Where does it all go pear-shaped?Thanks

Link to comment
Share on other sites

Just to clarify, the code for the javascript in the header reads:

<script type="text/javascript"><!--function SpAc(addr, WinName) {window.open(addr, WinName,'width=675,height=260');}//--></script>

Link to comment
Share on other sites

This code doesn't look right to me:<input class="accs" type="image" src="Images/SpAc_PumpSub.jpg" alt="Nutool Submersible Pump" title="Nutool Submersible Pump" value="SpAc01" onclick="SpAc('Accs/SpAc01.html').js" />And I see your function has two parameters:function SpAc(addr,WinName)and you're only calling it using one:SpAc('Accs/SpAc01.html')Other than that, you can remove the comments (<!-- -->) from the script tag, it really isn't much use.

Link to comment
Share on other sites

Thanks very much for help. Seems I have my thick head on today as...I still get no action and a debug request. Debugger narrative is "object required".Current code in html is:

<input class="accs" type="image" src="Images/SpAc_PumpSub.jpg" alt="Nutool Submersible Pump" title="Nutool Submersible Pump" value="SpAc01" onclick="SpAc('Accs/SpAcPump.html', 'Nutool Submersible Pump').js" />

SpAc.js (capitals as shown) is:

function SpAc(addr,WinName) {window.open(addr,WinName,'width=675,height=260');}

Link to comment
Share on other sites

You problem is that you keep on adding .js where you shouldn't:<input class="accs" type="image" src="Images/SpAc_PumpSub.jpg" alt="Nutool Submersible Pump" title="Nutool Submersible Pump" value="SpAc01" onclick="SpAc('Accs/SpAcPump.html', 'Nutool Submersible Pump').js" />Take it away and it should look like this:<input class="accs" type="image" src="Images/SpAc_PumpSub.jpg" alt="Nutool Submersible Pump" title="Nutool Submersible Pump" value="SpAc01" onclick="SpAc('Accs/SpAcPump.html', 'Nutool Submersible Pump')" />

Link to comment
Share on other sites

Thanks very much for help. Seems I have my thick head on today as...I still get no action and a debug request. Debugger narrative is "object required".Current code in html is:
<input class="accs" type="image" src="Images/SpAc_PumpSub.jpg" alt="Nutool Submersible Pump" title="Nutool Submersible Pump" value="SpAc01" onclick="SpAc('Accs/SpAcPump.html', 'Nutool Submersible Pump')" />

SpAc.js (capitals as shown) is:

function SpAc(addr,WinName) {window.open(addr,WinName,'width=675,height=260');}

Changes made - thanks you very much again - still no working. What links this html to the .js file? How is that called?
Link to comment
Share on other sites

If your javascript is in a separate page, then you have to put this in your <head> tags:<script src="file.js" type="text/javascript"></script>And inside the .js file you write the javascript without script tags, like this:function SpAc(addr,WinName) {window.open(addr,WinName,'width=675,height=260');}

Link to comment
Share on other sites

Thanks Ingol, but somehow it still won't work properly.Here is the code in SpAc.js

function SpAc(addr,WinName) {window.open(addr,WinName,'width=675,height=260');}

The code in the <head> section reads:

  <title>Systemwash UK Ltd - Spas, Saunas, Gazebos and Lifestyle Products - Howden, East Yorkshire</title>    <script src="SpAc.js" type="text/javascript"></script>  </head>

and the html reads:

<input class="accs" type="image" src="Images/SpAc_PumpSub.jpg" alt="Nutool Submersible Pump" title="Nutool Submersible Pump" value="SpAc01" onclick="SpAc('Accs/SpAcPump.html', 'Nutool Submersible Pump').js" />

All of which seem to be what I should have and how you confirm it should be. Why then does it all fall down?

Link to comment
Share on other sites

I'm still seeing an additional ".js" at the end of your function calling:<input class="accs" type="image" src="Images/SpAc_PumpSub.jpg" alt="Nutool Submersible Pump" title="Nutool Submersible Pump" value="SpAc01" onclick="SpAc('Accs/SpAcPump.html', 'Nutool Submersible Pump').js" />Take that away and the function should work just fine.

Link to comment
Share on other sites

Thanks so much Ingolme - I was so near yet so far lol. Ah well.Finally, this still fails in IE(7). I have narrowed it down (I think) to the spaces between words (or at least multiple words) in the WinName variable. Those with single word (e.g. 'Covershelf' and 'Traymate') work but not one other does (e.g. 'Tester Kit' and Cover Straps')What did I do wrong now?

Link to comment
Share on other sites

Window names can't contain spaces. Anyways, Nobody can see the name of the window, it's just used as a reference for the program. I recommend using a simple name for the window, like "newWindow" or something like that.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...