JavaScript - Manually Set Getvar?
Sorry about the very newby question but I know nothing about js...
I have a call to javascript on a web page. Within this script is the function function t202Init() within it I have var c1 = t202GetVar('c1'); This currently grabs the "c1" variable from the url and sets it. My problem is I want to set it manually without it being in the url. Is there a way to define this on the web page before the script is called? I can't really mod the js itself as this is a unique case and don't want to break it for other uses. Is there a way to define the t202GetVar('c1') w/o it being in the url? Thanks Similar TutorialsOne of the platforms I need to code for is a very (very very) old version of iceweasel (3.5.16). It does not support the "bind" function. So, I (naively) thought that writing a bind function might not be so difficult after all. I tried the following: Code: 'use strict'; if (typeof Function.prototype.bind === 'undefined') { Function.prototype.bind = function(newCaller) { this.caller = newCaller; } alert('Bind is now defined.'); //Do this to make sure that the conditional block is being entered. } window.onload = function() { try { myElement.addEventListener('click', this.doSomething.bind(this), false); //this is line 110 (see error message). } catch (e) { alert(e.toString()); } } However, this causes the following Error to be thrown: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://*** :: anonymous :: line 110" data: no]. What am I doing wrong? (I'm not sure I even understand the error message!) My javascript quits working when I am rendering the html? (It works perfectly fine if the page is opened from http address directly). I did some research and concluded that "JavaScript is executed on page load", so when I render my html, my JavaScript functions are not automatically called. My question is how should I call the javascript functions manually? verify.html: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML> <HEAD> <Title>form</Title> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <link rel="stylesheet" type="text/css" href="xupload.css"> </HEAD> <BODY> <form id="myform" enctype="multipart/form-data" action="/cgi-bin/upload.cgi" method="post" onSubmit="return StartUpload(this);"> <DIV id="div1"> <b><font id='x_max_files'>?</font> files <font id='x_max_size'>?</font> Mb total maximum</b> <div id="upload_input"><input id="my_file_element" type="file" name="file_1" size=58></div> <div id="files_list"></div> <p align=center><input type="submit" value="Upload Files" class="myForm" id="submit_btn"></p> </DIV> </form> <iframe src="javascript:false;" name="xupload" style="position:absolute;left:-9999px;"></iframe> <script type="text/javascript"> //Specify your form ID var x_form_id = 'myform'; var x_mode = 1; var x_tmpl_name = ''; </script> <script src="xupload.js" type="text/javascript"></script> </BODY> </HTML> config file: Code: htmlverify = "../verify.html" Perl: Code: if(my $verifypage = $g->{CV}{htmlverify}) { # passing variables xxxxx .... # render the page: send_header(); $p->pf($verifypage); } |