I got this error when using uniGUI framework for executing JS code.
Cannot read property 'scrollView' of undefined
This property is used in this procedure.
procedure SetScrollboxSize(AFramem: TWPUnimFrame; ASize: Integer);
begin
if ASize > AFramem.ScrollBoxm.ClientHeight then
UniSession.JSCode(AFramem.Scrollboxm.JSName
+ '.scrollableBehavior.scrollView.getScroller().maxPosition.y = '
+ (ASize - AFramem.Scrollboxm.ClientHeight).ToString + ';')
else
UniSession.JSCode(AFramem.Scrollboxm.JSName
+ '.scrollableBehavior.scrollView.getScroller().maxPosition.y = 0;');
end;
Can you give me a hint where to search or where to start to fix this bug?
It's difficult to reproduce your error without the actual source code, but "Cannot read property '...' of undefined" is typical JavaScript error. I guess that TWPUnimFrame is some kind of component for displaying web content.
In your case you need to make sure that AFramem.Scrollboxm.JSName + '.scrollableBehavior' variable is assigned. You may try to output some information with console.log() and debug JavaScript code:
procedure SetScrollboxSize(AFramem: TWPUnimFrame; ASize: Integer);
var
code: string;
begin
code := 'console.log(' + AFramem.Scrollboxm.JSName + 'scrollableBehavior.scrollView); ';
if ASize > AFramem.ScrollBoxm.ClientHeight then
code := code +
AFramem.Scrollboxm.JSName +
'.scrollableBehavior.scrollView.getScroller().maxPosition.y = ' +
(ASize - AFramem.Scrollboxm.ClientHeight).ToString + ';'
else
code := code +
AFramem.Scrollboxm.JSName +
'.scrollableBehavior.scrollView.getScroller().maxPosition.y = 0;';
UniSession.JSCode(code);
end;
Related
Im doing intro to JS in a site called CodeHS. I believe I did the assignment its asking of me right but it says its wrong?
Here is what it wants me to do:
Here is what I did:
Heres what I apparently got wrong:
Ive run this code many times and it worked flawlessly, so why does it give me these errors?
You forgot to add a blank line inside the end of your while block, which also accounts for the line number. You should check the IMPORTANT note on the assignment.
I agree with #Jorge. You need to include the new line character '\n' at the end of the appropriate print statements, for the sake of the marking program. Try it like this:
while(numItems > 0) {
println('We have ' + numItems + ' in inventory.');
var buy = readInt('How many items would you like to buy?');
if(buy <= numItems) {
numItems -= buy;
println('Now we have ' + numItems + ' left.' + '\n');
} else {
println('There is not enough in inventory for that purchase.' + '\n');
}
}
I have this code:
compareList[productName] = productID + ',' + productHref;
console.log(productName + ' ' + productID + ' ' + productHref + ' ' + compareList.length);
Which logs into this (I have removed the link):
Acer Iconia B1-790 [NT.LDFEE.002] 112576 link removed for confidentiality 0
As you can see, all three variables are valid strings, but the json object still fails to assign (compareList.length logs as 0). I've been thinking and thinking but I simply can't figure it out. Any help is appreciated.
Maybe this version of adding and checking array length can be useful to you?
var compareList=[]
var productName = {productID:'saban',productHref:'http://saulic.com'};
compareList.push(productName);
console.log(compareList.length);
Trying to dynamically set variables depending how many vimeo iframes are on my page. Im using the Eval method in my code below:
var numberVimeoFrames = jQuery(".vimeo").length;
for(i=1;i<=numberVimeoFrames;i++){
var refFrame = jQuery('.vimeo:nth-child(' + i + ')');
eval("player" + i + "= new Vimeo.Player(" + refFrame + ")");
}
My eval line is however generating an error message:
Uncaught SyntaxError: Unexpected identifier
To me it looks like ive concatenated correctly so not sure where ive gone wrong?
Even though in this case I do not think it is that bad, the general opinion is to not use eval at all.
Use arrays instead :
var numberVimeoFrames = jQuery(".vimeo").length;
var players = [];
for(i=1;i<=numberVimeoFrames;i++){
var refFrame = jQuery('.vimeo:nth-child(' + i + ')');
players.push(new Vimeo.Player(refFrame));
}
You can now access your players by calling the array (for example players[1] instead of player1 and so on.)
I was just going through the code of timer.js HERE. and came across the following lines of code:
var paramList = ['autostart', 'time'];
for (var arg in paramList) {
if (func[paramList[arg]] != undefined) {
eval(paramList[arg] + " = func[paramList[arg]]");
}
};
In the source code its all on one line, but i've made it more readable above , my difficulty is with the usage of eval, I.E. the below line of code:
eval(paramList[arg] + " = func[paramList[arg]]");
now if i add a breakpoint in chrome to the above line and go to the console and paste the line of code i get the following:
true
How come ? lets have a close look at the statement again:
eval(paramList[arg] + " = func[paramList[arg]]");
what is the + doing here ? converting paramList[arg] to a string , in which case eval is being used as follows:
eval("paramList[arg] = func[paramList[arg]]");
?
or is the plus sign being used for concatenation purpose ? (which i think is very unlikely !)
I have read MDN eval(), but still had doubts.
can anybody explain the breakdown of that statement please ?
Thank you.
eval takes a string. What you have:
eval(paramList[arg] + " = func[paramList[arg]]");
The + is just string concatenation.
Is equivalent to:
var code = paramList[arg] + " = func[paramList[arg]]"
eval(code);
So I'd say it should be equivalent to:
global[paramList[arg]] = func[paramList[arg]];
Or, in this particular example (with var paramList = ['autostart', 'time'];)):
if (func['autostart'] != undefined)
autostart = func['autostart'];
if (func['time'] != undefined)
time = func['autostart'];
What's the wrong with this Javascript line?
user: h.reem
domain: somedomain
var target = "//account/win/winlogin.aspx" +
"?username=" +
user.toString() +
"&domain=" +
domain.toString();
the resutl is always:
//account/win/winlogin.aspx?username=h.reem
Any idea!!
alert(user + "X") shows only h.reem
The ActiveX component is probably returning a null terminated string (I've seen this with Scripting.TypeLib & a couple of the AD objects for example) so concatenating it with another string fails. (You can verify this if 0 === user.charCodeAt(user.length - 1)).
You will need remove the last character before using the string;
user = user.substr(0, user.length - 1);
try:
var sUser = user.toString();
var sDomain = domain.toString();
var target = "//account/win/winlogin.aspx" + "?username=" + sUser + "&domain=" + sDomain;
The above might not fix your problem but it should expose it - Could be that your user.toString() method isn't returning a string and is short-circuiting things... If this doesn't answer your question I'd be glad to assist further, but it would be helpful if you posted the implementation or source of "user" somewhere ...