How To Modify Javascript Function To Take More Arguments.
Jan 23, 2007
I have an external javascript file with certain attributes defined to open a file in new window, which I use for viewing maps. However I need to define different attributes for the height and width, as I want users to open video clips in smaller windows. What do I need to do? Code:
What I want is a loop that will call the same function until it reaches a certain number (let's say 10). Then I want the function to take the parameter passed (the number) and use it in the function where ever you see a 1 below. Basically I want it to run on each element of the pub_name array and from the info gathered define a variable based on the number (example: display_pub_name_*). I have run some tests .....
I know in different languages (VB.Net,C++,C#) how to pass an argument to function in this code: <html> <head> <script language="Javascript"> <!-- hide function openNewWindow() { popupWin = window.open('[URL]', 'open_window', 'menubar, toolbar, location, directories, status, scrollbars, resizable, dependent, width=640, height=480, left=0, top=0') } done hiding --> </script></head><body> <a href="javascript:openNewWindow();">return to front page</a> </body></html>
I need to add several links in my page, so I need to pass indexes from links to main function, so I can open images in specific folder with indexes filenames. For example in vb Subname("text_to_pass_to_SubName") Public Sub SubName(ByVal function_text as string) End Sub
I have a main page that opens a pop up window when the user clicks a link. The pop up window is a menu and when the user clicks the item, it populates a form input element on the 'parent' window.
My question is: this new populated form element is the value that I use to change a style.
onchange does not watch this form element because of getelementbyid, so it doesn't trigger the function needed to change the style. onchange works fine if I just manually input a value into the text box.
Any other way to fire the function off when the user picks their selection from the pop-up window? I was thinking I could use window.opener.function()? But how do I pass the form from the parent window? From the pop up window, I don't use this.form, what do I use?something like window.opener.form[0] ?
I'm having problems when passing and element from HTML to a script. I have several rows for a person addresses and when one of those fields change I need to update the value of a flag (that is a hidden element).
I have a function which can be called with an unlimited number of arguments.
I want to call another function with exactly the same arguments. I know I can get the arguments in the arguments object, and as such also in an array, but how do you pass the elements of an array to another function as parameters?
Is there a way to pass arguments to the callback function used inside an addEventListener? I see that I can only list the name of the callback function. For eg, I use this:
var boldLink=document.getElementById('cmtbold'); boldLink.addEventListener("click", rBold, true);
I need the id of boldLink to be accessible from inside the function rBold()
Sorry, bad title. Anyway, is there a way to pass the arguments to an object instantiated via a constructor using the arguments object and have it expanded, so to speak, so that it doesn't appear as a single argument? I'm sorry, this explanation is just atrocious, but I can't think of exactly how to word it. Maybe an example...
Take for instance Function.apply. It takes 1-2 arguments, the first being the object to use as the context, and the second being either an array or an instance of the arguments object which are to be the arguments for the function. I want to do something similar but I want to also basically use the new operator so that I get back an object.
Here's a snippet of some of my code, maybe this will help:
I would like to display few calendar fields on the same page with different days disabled. I guess that the easiest way to do that would be to let thenoWeekendsOrHolidaysfunction take care of it but in order to do that I need to pass some values to it. How can I do that?
The above code would have to be embedded into the PHP file.
how can we go about doing that unobtrusively? Ie by not putting the code into the PHP files how can a different argument be passed to that function depending on what page is loaded?
This is related to the pop-up window. Below is the function related to pop-up window. function openPopUpDetailsMultiple(seqNum ,controllername ) { if (!popUpDetails||popUpDetails.closed) { popUpDetails=window.open("GetSCEventAddData?schandle=<!.schandle>&objID=<!.objID>&seqnum="+seqNum+"&controllername="+controllername+,"popUpDetails","toolbar=1,location=0,scrollbars=1,width=600,height=300,resizable=1,left=200,top=200"); }else{ popUpDetails.focus(); popUpDetails.location="GetSCEventAddData?schandle=<!.schandle>&objID=<!.objID>&seqnum=" + seqNum; } }
The problem I'm facing now is in this piece of code: ><a href=javascript:openPopUpDetailsMultiple('"+ scEv[i].sceSeq+"''"+ scEv[i].sceCntr +"')><img src=images/NsaMoreDetails.gif border=0 height=16 width=16 align=middle alt='View more details'>More details</a></td></tr></table></td></tr></table>"); I do not know how to send these (scEv[i].sceSeq,scEv[i].sceCntr) arguments. What might be the delimiter for these arguments.
This example is much simplified as the original script.VBScript is making a value, passes this to Javascript, which puts that value into a div tag.Now, as you see in the VBScript, the value contains a call to a javascript function. It shows perfectly in HTML, but the call can't be made when clicking the link.Is it possible in VBscript to write dynamic hardcoded javascipt function that pass arguments?
This post is about the jquery validation plugin. I am using the url() method to validate text fields for valid url input. It works fine, but I want a slight modification where I am checking whether a base directory has been added and not some individual page. For example, not [URL] but [URL]. Any way I can modify that url method to satisfy my needs?
I want to modify a local variable of the ready function set like so: $(function () { var modifyme = 0; ... }); I cant change the code setting the ready function, as I am writing only a greasemonkey userscript. I already tried using the .data("events") method, but it never listed the "ready" event. Any function so I can modify the variable!
How we can modify this function in order to make it in use for many displays?
HTML Code:
For example! I have this code, the select with id=one is the main one whatever I select from the drop down list One or two or three , the other menue appear" with id=two or id=three.
I'm working on some code and am running into brick walls. I'm trying to write out Javascript with Javascript and I've read the clj Meta FAQ and didn't see the answer, read many similar posts (with no luck though), and searched through the IRT.ORG Faqs (www.irt.org/script/script.htm).
The Javascript is designed to open an popup window and then inside that window call another script which will resize that window. There may be another way around this but the reason I tried this approach initially was that I wanted to call the onload handler in the popup window to resize the image only after the image had completely loaded. I've had some code in the primary Javascript file (showimage.js) before that works if the image has been cached but on the first load, it doesn't resize properly which tells me it is probably because it is trying to resize the window based on the image size but it isn't completely known at that point. So I removed that code and tried placing the resizing code in the second Javascript file (resizewindow.js). BTW I've tried other code to open a popup image and automatically size it ie Q1443 at irt.org but that doesn't do exactly what we need.
Even if there is another way to do this with one file, I still want to figure out why this isn't working in case I run into it in the future.
I thought what I would need to do to use document.writeln to write Javascript would be to escape any special characters and to break apart the script tag ie
document.writeln('</SCRIPT>');
would become
document.writeln('</SCR' + 'IPT>');
I have a HTML page and 2 Javascript files. All files are in the same directory and have permissions set correctly.
Here are the 3 files (keep in mind wordwrap has jacked up the formatting):
index.html ---------- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Test</title> <SCRIPT type="text/javascript" LANGUAGE="JavaScript1.1" SRC="showimage.js"> </SCRIPT> </head>
<body> Click the house<BR> <A ONCLICK="newWindow1('house1.jpg','Nice House')"><IMG SRC="house1thumb.jpg"></A> </body> </html>
showimage.js ------------ function newWindow1(pic,sitename) {
resizewindow.js --------------- function resizewindow() { // Do resizing here. // Right now this isn't being executed alert("resizing window"); }
Can anyone provide some pointers as to why this javascript is failing? I'm using IE6 on Win2k and when I click on the image to open the popup window, it does open the window but it is white with no content and the system immediately goes from about 4% CPU usage to 100% and consistently stays there until I kill that window with the task manager.
I'm getting errors in Firefox everytime I try to run this frame resize code, but it works fine in IE. I can't seem to figure out what the problem is with it.
The error is: Error: theFrame has no properties Line: 8
The line that the javascript console is showing an error for is in italics.
I have some javascript that I have written into the <body> section and it works great. But I would like to make it into a javascript function and define the function in the <head> section. Then in the <body> section write a small bit of javascript that would call the function() object. Code:
I embedded a javascript in HTML and tried to open the file using mozilla 1.4 it gave me the following exception in the script on clicking the Submit/Next button. IE was able to execute the script
Function defination function evaluate(form)
Line making the call : <INPUT onclick="if (validate(this.form)) evaluate(this.form);" type=button value=Submit/Next name=B1>