Fejl i funktion - men hvad?
Følgende ligger i filen test.js:// general purpose function to see if a suspected numeric input is a positive integer
function isPosInteger(inputVal) {
inputStr = inputVal.toString()
for (var i = 0; i < inputStr.length; i++) {
var oneChar = inputStr.charAt(i)
if (oneChar < “0” || oneChar > “9”) {
return false
}
}
return true
}
/*
LaunchBrowser takes the following arguments:
url: URL to open
title: Title of new window
width: pixels width of window
height: pixels height of window
location: Show locationbar (yes|no)
menubar: Show the menubar (yes|no)
scrollbars: Show the scrollbars (yes|no)
status: Show the statusbars (yes|no)
titlebar: Show the titlebar (yes|no)
toolbar: Show the toolbar (yes|no)
resizable: Can you resize the window (yes|no)
directories:Show the personal toolbar (yes|no)
*/
function LaunchBrowser(url, title, width, height, locationbar, menubar, scrollbars, statusbar, titlebar, toolbar, resizable, directorybar) {
params = ''
if(locationbar='no') params += 'location=no'
else params += 'locationbar=yes'
if(menubar='no') params += ',menubar=no'
else params += ',menubar=yes'
if(scrollbars='no') params += ',scrollbars=no'
else params += ',scrollbars=yes'
if(statusbar='no') params += ',status=no'
else params += ',status=yes'
if(titlebar='no') params += ',titlebar=no'
else params += ',titlebar=yes'
if(toolbar='no') params += ',toolbar=no'
else params += ',toolbar=yes'
if(resizable='no') params += ',resizable=no'
else params += ',resizable=yes'
if(directorybar='no') params += ',directories=no'
else params += ',directories=yes'
if(isPosInteger(width)) params += ',width=' + width
if(isPosInteger(height)) params += ',height=' + height
download = window.open(url, title, params)
}
i html-filen har jeg følgende elementer:
<script src="functions/test.js" language="JavaScript" type="text/javascript"></script>
<A HREF="java script:LaunchBrowser('http://tommy/', 'title', 300, 300, 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes');">Launch</A>
Det fungerer ikke når jeg klikker på linket, men jeg kan ikke regne ud hvorfor - og den fejlmelding jeg får kan jeg ikke bruge til så meget... :-/
