Passing Document As An Argument?
Apr 26, 2010Quite often, I define variables like so:
Code:
var something = (function () {
if (x) {
[code]....
Quite often, I define variables like so:
Code:
var something = (function () {
if (x) {
[code]....
how to you use the result of a function as the argument for another function instead of passing the actual function to it. i.e.
function foo2(){}
function foo(func){}
foo(foo2);
This passes foo2 to foo, can I do foo(foo2()) ? i.e. is the difference between whether a function is passed or evaluated dependent on whether you use "()" after the function name?
I'm trying to pass an array as an argument for a function on load of an html page, but can't seem to get it to work. Here is my code.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
[code]....
I am new to Jquery and would like to know, when we write a Jquery function and pass 'e' or any other word or letter as first argument, what does it represent? Also If I want to pass some parameter to my function along with 'e', how can I pass it?
View 1 Replies View RelatedGiven the following code:
var xf2;
function f1()
{
if (document.createElement && document.body && document.body.appendChild) {
xf2 = new f2(arguments[]);
}
}
I am getting a syntax error in the "new" statement following the [].
How do I pass the variable-length arguments list received by f1 on to f2?
What I wanted to do is to link to a new page having a date range input in the form of 6 text boxes, 2 sets of mm-dd-yy, from and to, where the upon loading the page box 1 of the from would auto focus and then auto tab and then post where php could take over on the server side. Setting up the form and the lay out, no problem. Auto focusing went just like expected using the following code, included because on the next step everything fell apart.
[/CODE]
<script type="text/javascript" >
window.onload=function() {
document.getElementById("input1").focus();
[Code].....
I am facing a problem in passing replace() function as an argument in user defined java function.
intention is to pass a file path to my user defined function, but before passing the path i want to replace the character '' to '\'
I am posting my javascript function here:
<a href="#" onclick="OpenDocPreview('<%# Eval("PATH")%>'.replace(/\/g,"\\"), '<%# Eval("Filename")%>')"><%# Eval("DocTitle") %></a>
function OpenDocPreview(url, docname) {
alert('message from search base : ' + url + ' ' + docname);
}
What syntax do I use to pass the div_name argument value to the rotate function in the setInterval function? I can't seem to get it to work.
Code JavaScript:
function theRotator(div_name) {
//Set the opacity of all images to 0
[code]....
I'm trying to pass titleArray and pointsArray to the task(); I'm getting an error mgs this.assignments() is not a function. I've highlighted this.assignments()
[Code]...
Im currently creating a Table with 2 frames (table in top, last row clicked in bottom)
<html>
<frameset rows = "60%, 40%">
<frame src = "table_driver.php" name = "A" id = "FRAME1">
<frame src = "bottom_row.php" name = "B" id = "FRAME2">
</frameset>
</html>
In bottom_row.php I have one object, a [obj = new TableData()]. onClick of a row in FRAME1, obj is initialized to what was clicked and the row is changed.
anyways currently I have it working but want it such that it can work with multiple frames, with a location parameter.
this is currently what I have
function TableData(headers, row, loc)
{
this.headerArr = headers;
this.rowArr = row;
[Code]....
Is there any way to pass the document context when doing a create element? If I have an iframe defined as follows..
var f = window.frames.myIframe;
How can I do this in jquery?
var d = f.document.createElement("div");
[code]....
i'm using a jQuery Inline Modal Window. the code for it can be found here
[URL]
i currently have an array within a function in javascript. when i click on the appropriate link for the inline modal, the inline modal window appears.
my function looks something like this
function match_all_groups(){
var pop_up_status;
var match_groups = new Array();
var match_groups_count = 0;
[Code]....
i want to receive values from match_groups and display them in my inline modal window. do u know how this can be done?
Does anyone have any coding rules they follow when doing argument checking?
When arguments fail during check, do you return from the call with an ambiguous return value, or do you throw exceptions?
If I try to append a PARAM tag twice I'm having problems:
var.medDiv = document.getElementById("myDiv");
var medObj = document.createElement("object");
var p = document.createElement("param");
p.setAttribute("FileName",this.URL);
medObj.appendChild(p);
p = document.createElement("param");
p.setAttribute("AutoStart","false");
medObj.appendChild(p); // <-- this one
medDiv.appendChild(medObj);
The line with the "this one" comment triggers IE to tell me that it has
an invalid argument. If I change the order of the PARAMs then the new
second PARAM will give me the error. If I move the setAttribute to after
the appendChild I still get the error.
Suppose I have a frame like 123bottom.html and within it, I want to promt
the user for a response (in the <HEAD>) like
var ans = prompt("What is your name?");
and then reload the page (via, say window.location.reload() ?)
using the argument of the value of ans appended onto the url so that, in
effect, say, I am calling the new frame as
123bottom.html?ans=Ike
Can someone show me how I need to call the page again, itself, like this
once I have the value for ans? Thanks, Ike (himself)
Can you pass an array reference to a constructor? I don't know if it's because the syntax is screwy or it's impossible, but the following doesn't work.
// row constructor with array called fields
function RowObject(fields)
{
this.fields=new Array();
this.fields=fields;
}
row=new RowObject(fields);
alert(row.fields[0])
How do you pass an argument to a function.
for example if you have a <span id = "test" onMouseOver ="myfunc(x)>
eg you have lots of differant span id's but you want then all to have a certain background-color with each individual on mouseover event without having to write separate code for each span id
eg <span id=" test2"onmouseover ="this.style.background ='red'>....
How can I modify any one of these global variable identified via a function
argument?
var x1 = "bla";
var x2 = "bla";
var x3 = "bla";
function modify(variable) {
???? [variable]???? = "blabla":
}
The following onclick should change the string value of variable 'x1' from
"bla" to "blabla", via the above modify() function.
<a ... onclick="modify('x1')">
I amreceivingthe following error on IE8:Invalid argument. jquery-1.4.2.js, line 5899 character 5 Now I have used the debugger, and this seems to be the only error it catches. And I realize that I could go through each line of what I wrote and figure out what line triggered this portion of jQuery. However in the interest of making jQuery better, I want to understand this error and fix it in the jQuery file.
[Code]...
I have used an object in the past as a function argument, but this was for a plugin that I wrote. Using it in the architecture of a plugin it worked. BUT, this time, I just want to write a normal function, but still use an object to set defaults and pass in changes to those defaults through as a param. Is this possible, or do I have to make this a jQuery function like $.myfunction() ?
[Code]...
i have an initAll() called on window.onload within initAll() I assign a few onclick handlers to some links. However, it would be great if I could pass an argument to the handler, so I could use the same handler every time... but if I include two brackets for each handler, it executes immediately... ignoring the 'onclick' bit...
window.onload = initAll;
function initAll(){
document.getElementById('btn_events').onclick = getSpecificFeed('events');
}
[code]....
This is a post relate to this post:DOM inside variable with innerHTML?To reduce any ambiguity this new thread deals with the code below.The previous post was more about how DOM can be used in a variable.This one has to do with a similar problem, but more with functions.
<html>
<head>
<title>Test</title>
[code]....
I've been trying to show a div using jQuery's show function with the scale effect. My code works fine in Firefox. When I test it in IE7, it breaks. I narrowed it down to either the origin argument of the scale effect, or the time argument of the show function (which seems unlikely). Like this:
Works in IE7, italics added to show commented code better:
Code:
$(document).ready(function() {
$("#hover").hover(
function() {$("#content_show").show("scale",{percent: 100, direction: 'vertical'});},//, origin: ['center','center']},500);},
[Code]....
Also, not as important, but what is the syntax of the origin property? What values can I use in it?
I'm finishing my javascript form validator (only text fields for now) and here's one of the last things that's left.
I'm using class names of input elements as parameters for my validator. To find them i use Element.hasClassName(id, class) method from prototype library. I want to implement minlength parameter - so i grab a regexp tutorial and after a minute i had something like this minlength[[1-9][0-9]*], which finds minlength[1], minlength[666] and so on.
Great, but how to pass this as a paramter to hasClassName method, which requires string as a className?
How can I create argument defaults for a function? I have this function (the purpose of the lines I included were to set defaults if the user forget to input something simply to prevent an error.
Code:
addHSLink = function (hsElem, hsUrl, hsType, hsTitle, hsWidth, hsHeight) { //hsElem[string], hsUrl[string], hsType[string], hsTitle[string], hsWidth[string/number], hsHeight[string/number]
var jQElem = $(hsElem);
if (typeof hsUrl !== 'string') {
hsUrl = '[URL]';
} if (typeof hsTitle !== 'string') {
hsTitle = '';
} if ((typeof hsWidth !== 'string' && isNaN(parseFloat(hsWidth))) || hsWidth !== 'number') {
hsWidth = 800;
} if ((typeof hsHeight !== 'string' && isNaN(parseFloat(hsHeight))) || hsHeight !== 'number') {
hsHeight = 600;
}
//Some other code
}
I would like to save some programming space and time by finding another way to set defaults. I saw somewhere that you could set a default in the arguments list
Code:
function someFunction(aVariable = false) {
//some code
}
But when I try to do this with all my arguments, I get the error:
"Missing ) after formal parameters".
I am trying to pass _marker to showEquipmentDataDiv() in the code below but I get a runtime error that says
Quote:
The alert(_marker.getTitle()) works so the marker is being passed to getLocationEquipmentHTML() correctly.
Code: