|
I've tried the following, and 'undefined' does not seem 'fakable' as you say. A local variable can assume another value, but the value of that variable is of course not assumes by undefined variables.
(function(window){
var undefined='a';
console.log(undefined);
console.log(window);
console.log(a);
})(undefined)
The following code also changes the local value of 'undefined', but not the 'undefined' of 'a' itself.
(function(undefined){
console.log(undefined);
console.log(a);
})('a')
|
|
|
|
|
It just shows how fundamentally 'undefined' is deep in the JavaScript engine...
As you (we) can not change it from the outside, you may talk to the committee...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Instead of 1.toString () we can use (1).toString().It will work fine by the java script perser.
|
|
|
|
|
Hi,
I am trying to make a simple javascript slideshow on my website. I'm not to bad with HTML and CSS but have no idea about javascript.
If someone could tell me why this slideshow is not working and exactly where and in what tags I need to put it in my code that would be amazing. I ideally want it to start when the user scrolls down to it (so when visible).
[^]
Thanks
|
|
|
|
|
I would like to track client mac address when he/she is browsing my website using javascript
|
|
|
|
|
JavaScript is not designed for this functionality, that is why there are server-side languages which can work around with request headers to provide you with other details of the client.
The following link works, only in Internet Explorer using ActiveX control (but still needs permission from user). http://stackoverflow.com/questions/16556700/how-to-get-client-mac-address-by-using-javascript[^]. I would still recommend, that you try to use server-side language such as ASP.NET, PHP etc to get these details.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
What is the proper syntax for incrementing or decrementing NOT by 1, but rather with another number in a For Loop? I am trying to count by threes and
"for(i=0;i<=30;i+3;) doesn't work. Why? The books and tutorials are great at telling you how to increment by 1 but rarely cover anything else.
|
|
|
|
|
The operator you are looking for is += like so:
<br />
for(i = 0; i <= 30; i += 3)
Also you have a spurious semicolon before the close bracket.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
For example:
if ($(e.target).parents('.jqx-tree').length > 0) {
return false;
}
return true;
WTF is the reason I can't just do a return on > comparison???
Marc
|
|
|
|
|
I can't reproduce the problem. Given:
var result = $(" ... ").length > 0;
alert(typeof result);
alert(result);
the code displays "boolean" and "true".
What output do you get if you try:
var result = ($(e.target).parents('.jqx-tree').length > 0);
alert(typeof result);
alert(result);
return result;
As a last resort, there's always the "!! " trick to convert to a boolean value:
return !!($(e.target).parents('.jqx-tree').length > 0);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yeah, it looked like a boolean to me too!
!! didn't work, but SO provided what I think is a better solution anyways:
function disableBrowserContextMenu() {
$(document).on('contextmenu', function (e) {
if ($(e.target).parents('.jqx-tree').length > 0) {
e.preventDefault()
}
});
}
Note the e.preventDefault() . Somehow, the explicit return true/false must have been doing this behind the scenes, I'm wildly guessing.
Marc
|
|
|
|
|
|
Richard Deeming wrote: In jQuery event handlers,
Heh, this is what happens when a noob (which I still consider myself) starts doing Javascript. Good to know, and thank you for the great info!
Marc
|
|
|
|
|
I didn't know that !! operator. Thanks.
Removed irrelevant content
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
To take a stab at the original question, jquery functions always return collections which is why a) can chain things b) never have to check for nulls. If $(e.target) returned a single thing and parents('.jqx-tree') returned a single thing then your code would make sense and work. But you actually have a foreach loop acting on a foreach loop...the first $() returns a collection (even if that collection only has one item) and the .parents works on each item in that collection and returns its own collection which your .length acts on. Now imaging $(..) returns 3 items (a, b and c) and the .parents of each of those items returns 1,0 and 5 items.
a.parents.length = 1
b.parents.length = 0
c.parents.length = 5
now your code
if ($(e.target).parents('.jqx-tree').length > 0)
makes less sense, which "length" are you evaluating? This idea about returning collections is probably what is stopping your code from working how you would expect. Maybe someone might know better.
|
|
|
|
|
But e.target will be a single DOM element, so $(e.target) will be a jQuery wrapper containing a single element.
And even if it contained three elements, the .parents(...) call would return a jQuery wrapper containing the matching parents of all three elements. So in your example, the .length property would return 6.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: But e.target will be a single DOM element, so $(e.target) will be a jQuery wrapper containing a single element.
It will be a collection that contains a single element.
new string[]{"hello"}
is not interchangeable with
"hello"
Like I said, I don't know js well enough to know if this is the reason that the original code isn't working as intended, I'm just saying it might be a possible reason.
|
|
|
|
|
All jQuery wrapper objects are collections, whether they contain multiple elements, a single element, or no elements.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yes, that's what I'm saying
|
|
|
|
|
We need to get client system date and time format. At present in our application we have requirement when user login into the application they have to see the date and time format as his local PC date and time format setting.
For example he is accessing the site form the then he able to see exact his local system date and time format instead of server format.
We tried this approach by using. date.toLocaleDateString() but this is returning the current local system date instead of format. Even this date.toLocalDateString() is behaving differently in different browsers.
So, please assist me how to get exact customize date and time format of client system.
Example: like (dd/MM/yyyy hh:mm, MM/dd/yyyy hh:mm and so on).
Please see this link what i am expecting
http://screencast.com/t/wgrgvHmDrY[^]
Thanks
|
|
|
|
|
Hi,
I want to fetch data from SQL database, and display the same on my HTML page in table format using Angular JS.
I am able to get the data in the scope variable, but it is not getting displayed in the HTML page.
Please check the code that I have written below, and help me fixing the issue.
Thanks in advance.
HTML code:
<html>
<head>
<title>:: View Logs ::</title>
<script src="Scripts/angular.js"></script>
<script src="Scripts/angular.min.js"></script>
<script src="Scripts/logsController.js"></script>
<script src="Scripts/jquery-2.1.1.js"></script>
<script src="Scripts/jquery-2.1.1.min.js"></script>
</head>
<body>
Log ID | User Type | User Name | Email ID | Action Type | Section Name | Section Details | DateTime | User IP |
---|
{{item.LogID}} | {{item.UserType}} | {{item.UserName}} | {{item.EmailID}} | {{item.ActionType}} | {{item.SectionName}} | {{item.SectionDetails}} | {{item.DateTime}} | {{item.UserIP}} |
</body>
</html>
logsController.js code:
angular.module('ViewLogsApp', [])
.controller('ViewLogsController', [
'$scope', function ($scope) {
$scope.logslist = [];
$scope.load;
$scope.load = function () {
$.ajax({
type: 'GET',
contentType: 'application/json; charset=utf-8',
url: 'UserActivityLogs.aspx/getList',
success: function (data) {
$scope.logslist = data
$scope.$apply();
}
});
}
$scope.load();
}
]);
WebMethod code:
[System.Web.Services.WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public static List<useractivitylogslist> getList()
{
SqlConnection con = new SqlConnection();
con.ConnectionString = _connstr;
con.Open();
var logs = new List<useractivitylogslist>();
string get = "select * from UserActivityLogs";
//string get = "sp_employee";
SqlCommand cmd = new SqlCommand(get, con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
UserActivityLogsList e = new UserActivityLogsList();
e.LogID = Convert.ToInt32(dr[0]);
e.UserType = Convert.ToString(dr[1]);
e.UserName = Convert.ToString(dr[2]);
e.EmailID = Convert.ToString(dr[3]);
e.ActionType = Convert.ToString(dr[4]);
e.SectionName = Convert.ToString(dr[4]);
e.SectionDetails = Convert.ToString(dr[4]);
e.DateTime = Convert.ToString(dr[4]);
e.UserIP = Convert.ToString(dr[4]);
logs.Add(e);
}
con.Close();
return logs;
}
Clouds come floating into my life, no longer to carry rain or usher storm, but to add color to my sunset sky. ~Rabindranath Tagore
|
|
|
|
|
Try to display the data of single column first.
To make sure if you are really getting your data at javaScript level and to make sure if your $scope is really working fine first try this snippet in your html. If it works than try all columns.
If it does not work than try this in your html and body tags
and
hopefully it would work....cheers
|
|
|
|
|
Just a rhetorical question...but sometimes when I'm looking for the correct code, things get so convoluted! When I figure it out, like how to stop a timer with the clear interval...face palm! It was so easy! I feel like there is something missing from my understanding or just my novice status, needing more experience. Thanks all for listening/reading my "moment".
|
|
|
|
|
What was the issue you found by yourself.... let me check if our understanding matches with you....
|
|
|
|
|
I want to create an array containing graphic GIF files (or pointers to the files) such that I can access and show the file with: document.write(array[gif1]);
I am new at Javascript. If there is something better than document.write, I'm open for suggestions.
Thanks,
Ray
|
|
|
|