|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi
I created this script so that you could point to files on your harddrive but whenever I try going to them it always comes up not available. Could somebody look at it? <!-- SOURCE CODE FOR control.htm --> <HTML> <!-- SOURCE CODE FOR wait.htm --> <HTML> <BODY> <H1>Please Wait ...</H1> </BODY> </HTML> thx Josh <!-- SOURCE CODE FOR TOP-LEVEL FRAMESET --> <HTML> <HEAD> <TITLE>Example 9.2</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!-- HIDE FROM OTHER BROWSERS // // WE NEED TO INCLUDE THE COOKIE FUNCTIONS // // // Cookie Functions - Second Helping (21-Jan-96) // Written by: Bill Dortch, hIdaho Design <bdortch@netw.com> // The following functions are released to the public domain. // // "Internal" function to return the decoded value of a cookie // function getCookieVal (offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } // // Function to return the value of the cookie specified by "name". // function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } // // Function to create or update a cookie. // function SetCookie (name, value) { var argv = SetCookie.arguments; var argc = SetCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } // Function to delete a cookie. (Sets expiration date to current date/time) // function DeleteCookie (name) { var exp = new Date(); exp.setTime (exp.getTime() - 1); // This cookie is history var cval = GetCookie (name); document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } // // END OF THE COOKIE FUNCTIONS. OUR SCRIPT STARTS HERE. // function getURL(frame) { var name = GetCookie(frame); return GetCookie(name); } function initialize() { if (GetCookie("sites") == null) { var expiryDate = new Date(); expiryDate.setTime(expiryDate.getTime() + (365 * 24 * 60 * 60 * 1000)); SetCookie("sites","CNN,USA-Today,Yahoo",expiryDate,"/"); SetCookie("CNN","http://www.cnn.com/",expiryDate,"/"); SetCookie("USA-Today","http://www.usatoday.com/",expiryDate,"/"); SetCookie("Yahoo","http://www.yahoo.com/headlines/news/",expiryDate,"/"); SetCookie("frameOne","CNN",expiryDate,"/"); SetCookie("frameTwo","USA-Today",expiryDate,"/"); SetCookie("frameThree","Yahoo",expiryDate,"/"); SetCookie("number","3",expiryDate,"/"); } } initialize(); var frameOne = getURL("frameOne"); var frameTwo = getURL("frameTwo"); var frameThree = getURL("frameThree"); // STOP HIDING HERE --> </script> </HEAD> <FRAMESET COLS="35%,*" onLoad="parent.frames['frameOne'].location=frameOne; parent.frames['frameTwo'].location=frameTwo; parent.frames['frameThree'].location=frameThree;"> <FRAME SRC="control.htm" NAME="control"> <FRAMESET ROWS="33%,33%,*"> <FRAME SRC="wait.htm" NAME="frameOne"> <FRAME SRC="wait.htm" NAME="frameTwo"> <FRAME SRC="wait.htm" NAME="frameThree"> </FRAMESET> </FRAMESET> </HTML> <HEAD> <TITLE>Example 9.3</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!-- HIDE FROM OTHER BROWSERS // // WE NEED TO INCLUDE THE COOKIE FUNCTIONS // // // Cookie Functions - Second Helping (21-Jan-96) // Written by: Bill Dortch, hIdaho Design <bdortch@netw.com> // The following functions are released to the public domain. // // "Internal" function to return the decoded value of a cookie // function getCookieVal (offset) { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } // // Function to return the value of the cookie specified by "name". // function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } // // Function to create or update a cookie. // function SetCookie (name, value) { var argv = SetCookie.arguments; var argc = SetCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } // Function to delete a cookie. (Sets expiration date to current date/time) // function DeleteCookie (name) { var exp = new Date(); exp.setTime (exp.getTime() - 1); // This cookie is history var cval = GetCookie (name); document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } // // END OF THE COOKIE FUNCTIONS. OUR SCRIPT STARTS HERE. // function getURL(frame) { var name = GetCookie(frame); return GetCookie(name); } var expiryDate = new Date(); expiryDate.setTime(expiryDate.getTime() + (365 * 24 * 60 * 60 * 1000)); var number = parseInt(GetCookie("number")); var siteList = GetCookie("sites"); var sites = new createArray(number); sites = extractSites(siteList,number); function createArray(num) { for (var i=1; i <= num; i++) this[i] = ""; this.length = num; } function extractSites(list,num) { var results = new createArray(num); var first = 0; var last = 0; for (var i = 1; i <= num; i ++) { first = (i == 1) ? 0 : last+1; last = (i == num) ? list.length : list.indexOf(",",first+1); results[i] = list.substring(first,last); } return results; } function makeList() { var result = ""; for (var i = 1; i <= number; i++) { result += sites[i]; result += (i == number) ? "" : ","; } return result; } function getList(frame) { var result = '<SELECT NAME="' + frame + '" onChange="loadURL(this);">'; for (var i = 1; i<=number; i++) { result += '<OPTION>'; result += (GetCookie(frame) == sites[i]) ? " SELECTED" : ""; result += ">" + sites[i] + "n"; } result += "</SELECT>"; return result; } function addURL(form) { if ((form.name.value == "") | | (form.name.value == null)) { returnl } var name = form.name.value; var url = form.url.value; SetCookie(name,url,expiryDate,"/"); sites[++number] = name; SetCookie("sites",makeList(),expiryDate,"/"); SetCookie("number",number,expiryDate,"/"); window.open("control.htm","control"); } function deleteURL(form) { var name = form.name.value; var gone = false; for (var i=1; i<=number; i++) { if (sites[i] == name) { gone = true; number--; for (var j=i; j<=number; j++) { sites[j] = sites[j+1]; } sites[number+1] = null; break; } } if (gone) { SetCookie("number",number,expiryDate,"/"); SetCookie("sites",makeList(),expiryDate,"/"); var today = new Date(); SetCookie(name,GetCookie(name),today,"/"); } window.open("control.htm","control"); } function loadURL(field) { var frame = field.name; var index = field.selectedIndex; var name = field.options[index].text; var url = GetCookie(name); window.open(url,frame); SetCookie(frame,name,expiryDate,"/"); } // Set things up before building forms var oneList = ""; var twoList = ""; var threeList = ""; oneList = getList("frameOne"); twoList = getList("frameTwo"); threeList = getList("frameThree"); // STOP HIDING HERE --> </script> </HEAD> <BODY> <H1>The<BR>News<BR>Source</H1> <SCRIPT LANGUAGE="JavaScript"> <!-- HIDE FROM OTHER BROWSERS document.write("<FORM METHOD=POST>"); document.write("Source One:"); document.write(oneList); document.write("</FORM>"); document.write("<FORM METHOD=POST>"); document.write("<BR>"); document.write("Source Two:") document.write(twoList); document.write("</FORM>"); document.write("<FORM METHOD=POST>"); document.write("<BR>"); document.write("Source Three:"); document.write(threeList); document.write("</FORM>"); // STOP HIDING --> </SCRIPT> <BR> <FORM METHOD=POST> Name: <INPUT TYPE="text" NAME="name"> <BR> URL: <INPUT TYPE="text" NAME="url"> <BR> <INPUT TYPE="button" VALUE="Add URL" onClick="addURL(this.form);"> <BR> <INPUT TYPE="button" VALUE="Delete URL" onClick="deleteURL(this.form);"> </FORM> </BODY> </HTML> |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > I can't figure out what is wrong! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|