|
thanks Richard, both work!
I thought I'd tried the first option before, but might have put it in the wrong place or had something else wrong at the time).
|
|
|
|
|
Hi All,
This Tab Add/Close functionality working as a static . I want to how to dynamically Add/Close tab items.
implemented code :
<html>
<head runat="server">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="js/JavaScript.js"></script>
<script type="text/javascript">
function openfunc()
{
winGoogle = window.open("http://google.com");
winGmail = window.open("http://gmail.com");
winMsdn = window.open("http://msdn.com");
winyahoo = window.open("http://yahoo.com");
windeveloper = window.open("http://developercenter.azurewebsites.net/");
}
function closefunc()
{
winGoogle.close();
winGmail.close();
winMsdn.close();
winyahoo.close();
windeveloper.close();
}
</script>
</head>
<body>
<h1>Multiple Tab</h1>
<input type="button" value="Open tab" onclick="openfunc()"/>
<input type="button" value="Close all tab" onclick="closefunc()"/>
</body>
</html>
How to implemented dynamically
Thanks,
|
|
|
|
|
I am trying to write code for my calendar next and previous buttons. But after a lot of tries I still can't figure it out. Here is HTML:
<div class="calendar-container">
<div class="calendar-header">
<a href="#" class="arrows" id="prevArrow">
<div class="prev-arrow-container"></div>
</a>
<div class="year-month-selector">
<select id="year" class="select-properties"></select>
<select id="month" class="select-properties"></select>
</div>
<a href="#" class="arrows" id="nextArrow">
<div class="next-arrow-container"></div>
</a>
</div>
<div class="calendar-body" id="calendar-body">
<div class="day-names" id="dayNames"></div>
<div id="days-container"></div>
</div>
</div>
Here is some JS:
setHandlers() {
var prevButton = document.getElementById('prevArrow');
var nextButton = document.getElementById('nextArrow');
nextButton.addEventListener('click', function () {
this.next();
}.bind(this));}
next() {
var currentYear = this.currentDate.getFullYear();
var currentMonth = this.currentDate.getMonth();
if (currentYear === YEAR_END && currentMonth === 11) {
return;
}
this.currentDate.setMonth(currentMonth + 1);
this.setDate();}
setDate() {
var currentYear = this.currentDate.getFullYear();
var currentMonth = this.currentDate.getMonth();
this.yearSelector.selectedIndex = currentYear - YEAR_START;
this.monthSelector.selectedIndex = currentMonth;}
createDays() {
var daysContainer = document.getElementById('days-container');
var newDate = new Date(this.currentDate.getFullYear(), this.currentDate.getMonth() + 1, 0);
var lengthOfMonth = newDate.getDate();
var date = 1;
for (var i = 0; i < 42; i++) {
var day = daysContainer.children[i];
if(i < this.startingCell) {
day.innerText = "prev";
day.style.opacity = '.2'
} else if (i > this.startingCell + lengthOfMonth){
day.innerText = "next";
day.style.opacity = '.2'
} else {
day.innerText = date;
date++;
}
}}
The whole source can be found here. Any kind of help is appreciated. It would be okay that you give hints about how to link one of the buttons to the calendar-body, that is when of the prev/next is clicked the calendar-body content is changed respectively back and forward. Thanks in advance.
|
|
|
|
|
What is your question? I'm not sure many people are going to be willing to download all your code and try to figure out what you want it to do.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hello ,
In our project we have parent page in which all required js files are included ,
but in one jsp I want to override the fusioncharts.js file which is of different version but older version of this file is already included in parent container,so when I am including it in my jsp it referring to the fusioncharts.js which is included in parent container.
Could you help me in how can I override the JS file in my JSP.
Thanks in Advance
Amol.
|
|
|
|
|
Good day friends! I am working on a site and in this site there is HTML link. On click event of the link am calling JavaScript function which is running fine. but when I specify the href of the link the JS function is discarded.
|
|
|
|
|
There might be an exception, check your console for errors. F12 for development tools and then check Console for any messages.
Also, use event.preventDefault() to stop the browser from navigating away upon click on the link,
function onclickhandler() {
event.preventDefault();
}
This will do what you need.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
thanks for the reply. the link button is Compose. what if person click on Inbox link and from Inbox page click on Compose link? For sure the person will be redirected to Compose page but the popup div appears and disappear after complete load of the page. Any help please.
|
|
|
|
|
Then, in such cases if you only want to dynamically update the content instead of having to manage events, I recommend using Single-page applications.
If not, then use my suggestion, that was the answer to disable the browser from navigating to that link itself, you can run the logic as needed.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
How are we supposed to know what is happening without being able to see anything?
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Magic!
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hi All,
I have a script which downloads the file from the server. Its was working fine, but its throwing error now.
I am getting error while creating the object using WScript.
please let me know how to fix this issue.
<html>
<head>
<script Language ="Javascript">
var userId = "fm012097";
window.alert(userId)
var password = "Bllchr1$";
window.alert(password)
var localDirectory = "c:\\temp";
window.alert(localDirectory)
var oHDL = WScript.CreateObject( "DSTHTTPDL.DownloadManager" );
oHDL.Host = "xyz.com";
oHDL.Target = "/sample";
alert(oHDL.Target)
oHDL.Client = "415171403";
oHDL.UseProxy = false;
oHDL.UseHttps = true;
oHDL.Asynchronous = false;
oHDL.UserID = userId;
oHDL.Password = password;
oHDL.LocalDirectory = localDirectory;
window.alert(oHDL)
var fileListing = oHDL.GetFileListAsXML();
window.alert(fileListing)
var xmldoc = WScript.CreateObject( "Msxml2.DOMDocument.4.0" );
xmldoc.async = false;
xmldoc.preserveWhiteSpace = true;
xmldoc.loadXML( fileListing );
var dListing = "";
var docelement = xmldoc.documentElement;
window.alert(docelement)
var iCount = 0;
if ( docelement.hasChildNodes() )
{
var nodeList = docelement.childNodes;
var node = nodeList.nextNode();
while ( node != null )
{
var file = node.getAttribute( "name" );
var display = node.getAttribute( "short-name" );
window.alert(file+''+display)
dListing += file;
dListing += ";";
iCount++;
node = nodeList.nextNode();
}
}
oHDL.DownloadFiles( dListing )
oHDL = null;
</script>
</head>
</html>
|
|
|
|
|
That is simple, how are you telling JavaScript, where to look for WScript definition? It requires JScript by Microsoft and will only run on Windows, where you can execute wscript.exe executable.
For example, look here javascript - ReferenceError: WScript is not defined - Stack Overflow[^], or here, VBScript and CreateObject issue - Stack Overflow[^]. Then again, it would heavily require clients to have dependencies installed.
If the purpose is just to download, why can't you use native JavaScript, or a minimal C++ program?
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
The error would tell you what the problem is. Is there a reason you did not include the error?
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hi,
I was wondering if someone could please help me with the following code as it doesn't seem to be working and I cant work out why. Basically, I am attempting to create a document referrer so if a user on a website comes from X site (that site only) then they are redirected to A but if they come from Y they are redirected to B, while if they come from an internal source then they can continue.
The code is:
<pre lang="Javascript">
var regExp = /https:\/\/(anon.to)\/(xxxxxx)/g;
var dr = document.referrer;
if (dr == '') {
self.location='WebsiteExample1';
} else if (dr.match(regExp)) {
self.location ='Otherplaceonwebsite';
}
The code works if I just use var regExp = /https:\/\/(anon.to)/g; but that allows anyone from anon.to to access the link rather than just the users with the https://anon.to/xxxxxx link.
Hopefully this makes sense and someone can help.
Thanks,
|
|
|
|
|
Quote: Create a secure anonymous short link from your url which also hides http referer!
The service you're using deliberately hides the referrer information. Therefore, you can't use the referrer to detect whether the user came from your anon.to link.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
function getLocation() {
navigator.geolocation.getCurrentPosition(function (pos) {
var lat = pos.coords.latitude;
var lng = pos.coords.longitude;
if (lat == null) {
navigator.notification.alert("GPS not activated!", null, "GPS", "Ok");
}
else {
navigator.notification.alert("Latitude: " + lat + " , Longitude: " + lng, null, "GPS", "Ok");
}
});
}
|
|
|
|
|
I have deleted your other versions of this question, please post once only. Also, you need to explain what your problem is.
|
|
|
|
|
Even a device has active GPS it is possible that your JS code will not benefit from this, that because browsers will not let you know the location without permission from the user... The problem is that browsers remember the hoise for every site, so once the user voted 'no' you have no way to force him choose again...
But, there is one way may help you... Connect 'getCurrentPosition' - directly - to a button click, in this case it considered as an action by the user and will be permitted... Of course you have to exactly describe to the user what will happening what clicking the button...
A good reading: Geolocation - Dive Into HTML5[^]
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
Quote: How to find user device is gps is on or off Android or ios using js? You are aware of the fact that GPS is a system feature in Android and not a browser feature, right? You can get the location, but to detect or determine you will have rely on the user, as browser won't be able to trigger changes itself.
Offline devices will return the most recent locations, not accurate or live locations. If you mean to say that location APIs are available then read here,
Common sources of location information include Global Positioning System (GPS) and location inferred from network signals such as IP address, RFID, WiFi and Bluetooth MAC addresses, and GSM/CDMA cell IDs, as well as user input. No guarantee is given that the API returns the device's actual location. So, you can simply request the users to enable GPS for better results.
Also, you should try to check for navigator.geolocation to be set to null or not, otherwise results may be generated.
if (navigator.geolocation) {
} else {
}
For more,
javascript - how capturing geolocation with device offline - cordova - Stack Overflow[^]
Accessing GPS data with JavaScript in real time - Geographic Information Systems Stack Exchange[^]
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
I'm trying to understand two way binding in AngularJS but I'm unable to understand the behavior of functions and variables.
Consider the following example:
So, I have a controller like this:
var app=angular.module("cal", []);
app.controller("calc",function ($scope) {
$scope.result=Number($scope.a || 0)+ Number($scope.b || 0);
});
and HTML like this:
<div ng-app="cal">
<div ng-controller="calc">
<input type="text" ng-model="a"/>
<input type="text" ng-model="b"/>
<span>{{result}}</span>
</div>
</div>
This code doesn't update the variable "result".
However, if I use something like this:
var app=angular.module("cal", []);
app.controller("calc",function ($scope) {
$scope.add = function(){
return (Number($scope.a || 0)+ Number($scope.b || 0));
}
});
and
<div ng-app="cal">
<div ng-controller="calc">
<input type="text" ng-model="a"/>
<input type="text" ng-model="b"/>
<span>{{add()}}</span>
</div>
</div>
the value in gets updated automatically with variation in variables "a" or "b".
How does this work? What's the difference in returning from the function and using the variable directly in the DOM?
|
|
|
|
|
There's a few ways to handle this, but since this is a basic operation you can do it directly in the angular tag. I would just advise declaring your scope properties in the controller for stability.
app.controller('calc',['$scope',function($scope){
$scope.a = 0;
$scope.b = 0;
});
<div ng-app="cal">
<div ng-controller="calc">
<input type="text" ng-model="a"/>
<input type="text" ng-model="b"/>
<span>{{ a + b }}</span>
</div>
</div>
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
I get this but this isn't what I asked. I want to know why using the variable "result" doesn't work. Doesn't Angular update it along with variables "a" and "b"?
|
|
|
|
|
Well, because you're assigning it as part of controller construction. If you want it to update then you'll need to watch the source variables:
app.controller('calc',['$scope',function($scope){
$scope.a = 0;
$scope.b = 0;
$scope.result = 0;
$scope.calculate = function(){
$scope.result = $scope.a + $scope.b;
}
$scope.$watch('a',$scope.calculate);
$scope.$watch('b',$scope.calculate);
});
Personally I think in this sort of operation that an aggregate variable is overkill, and it would be better to directly inject $scope.a and $scope.b into a request, if that's what you're goal is.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
Yes, but why don't we have to watch in case of using "add()"? Does Angular watch for functions automatically and for using variables in view do we have to watch them manually?
|
|
|
|