|
Looks like a weird browser bug to me. I've had a play with your script and found an ugly workaround by blurring the select box in the onchange handler:
document.forms[0].sel.onchange = function() {
var opt = this.options[this.selectedIndex];
this.form.debugga.value += "[click:"+opt.text+"] ";
opt.text += '#';
this.blur();
}
|
|
|
|
|
I want to save a file in a folder.I have a textbox with browse button and [SAVE] button i could browse the file but i am not able to save that same file in that folder.
Its urgent plz help..
|
|
|
|
|
Because of security reasons, file system is not accessible in JavaScript. You can try to write an ActiveX but will only be for IE.
In HTML5, there is a new API that can help but it has limitations like specific browser versions support.
|
|
|
|
|
I am currently converting asp pages to User Controls. In one of these pages a javascript timer displays the current time into a text block. Currently, the asp pages uses the javascript below. How do I move the timer javascript to a asp User Control and initialize it when the control loads?
<script type="text/javascript">
window.setInterval('timer();',1000);
function timer()
{
var d=new Date();
var t=d.toLocaleTimeString();
document.getElementById("TimerValue").innerHTML=t;
}
</script>
Thanks,
Steve Holdorf
-- modified 2-Apr-13 6:31am.
|
|
|
|
|
Hi. Also, when I run the code I get the following exception:
http://localhost:49334/ScriptResource.axd?
Microsoft JScript runtime error: Sys.ArgumentException: Value must not be null for Controls and Behaviors.
parameter name element
And the code the execption is on in the debugger is:
throw Error .argument('element', Sys.Res.createNoDom);
|
|
|
|
|
I got it working. I had some commented out code in my Ajax portion that was causing the error!
Steve Holdorf
|
|
|
|
|
I'm going crazy here. I've used this code for years and never had a problem. I tested a previous version of the the regex string for Canadian Postal Codes and it worked fine. But today doing a DHL Shipping upgrade testing on Canadian Addresses, I can't get my Canadian Postal Code Regex to produce a match.
So I'm trying K1A 0G9, K8N 5W6, LDU 9Z0
for example. I ran some test in RAD Regex Expresson tester, and could not produce a match as well using
/^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$/
Wait, I just tried this and got a match with the RAD Regex Expression tester, hmm
^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ] \d[ABCEGHJKLMNPRSTVWXYZ]\d$
This seems to work with every variation in the RAD tester, maybe this one
^[ABCEGHJKLMNPRSTVXYabceghjklmnprstvxy]{1}\d{1}[A-Za-z]{1} *\d{1}[A-Za-z]{1}\d{1}$
Wish a real Canadian would enlighten me on this one.
I must admit the canadian postal code system is pretty slick, but not sure why I have so much trouble with it.
var match_b_PostalCode;
var re_Shipping_PostalCode_CA = new RegExp("^[ABCEGHJKLMNPRSTVXY]\\d[ABCEGHJKLMNPRSTVWXYZ]( )?\\d[ABCEGHJKLMNPRSTVWXYZ]\\d$/i");
var re_Shipping_PostalCode_MX = new RegExp("^\\d{5}(-\\d{4})?$");
var re_Shipping_PostalCode_US = new RegExp("^\\d{5}(-\\d{4})?$");
var txt_Shipping_PostalCode = $('[id*="_txt_Modal_ShipRate_AddressInput_PostalCode_Field"]').val().toUpperCase().trim();
switch (countryCode_Value) {
case "CA":
match_b_PostalCode = re_Shipping_PostalCode_CA.exec(txt_Shipping_PostalCode);
case "MX":
match_b_PostalCode = re_Shipping_PostalCode_MX.exec(txt_Shipping_PostalCode);
case "US":
match_b_PostalCode = re_Shipping_PostalCode_US.exec(txt_Shipping_PostalCode);
}
|
|
|
|
|
Figured it out in jFiddler, I forgot to put breaks in the switch statement, stupid me!
|
|
|
|
|
Am not sure what I’ve done wrong. The below code is supposed to show the time and date as Time|Date: 16:08:24 31/3/2013, however its now showing up as Time|Date: 16:08:24 0/3/2013…
<script>
function startTime()
{
var today=new Date();
var d=today.getDay();
var dt=today.getDate();
var mt=today.getMonth() + 1;
var y=today.getFullYear();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
m=checkTime(m);
s=checkTime(s);
document.getElementById('txt').innerHTML= "Time|Date:"+" "+h+":"+m+":"+s+ " " + d+"/"+mt+"/"+y;
t=setTimeout(function(){startTime()},500);
}
function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
</script>
Note: Everything else is fine except for the date, what with it bring up '0' instead of '31'
|
|
|
|
|
You have used d instead of dt in getElementById line. Sunday = 0
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
|
|
|
|
|
So on my site I've got a panel that slides out using Jquery, in that panel / div I've put a HTML5 game, the game works fine as a stand alone html document but I wanted to add it as a little surprise into a slide panel, however for the life of me I cannot keep the focus on canvas.
I've tried setting the tab index in the css to 1.
Here's the code I'm using.
var canvas = document.createElement("canvas");
var ctx = canvas.getContext("2d");
canvas.width = 512;
canvas.height = 480;
canvas.id="gameCanvas";
div = document.getElementById("slide-panel");
div.appendChild(canvas);
$(document).ready(function(){
$(".btn-slide").click(function(){
document.getElementById('gameCanvas').focus()
});
});
Simon Lee Shugar (Software Developer)
www.simonshugar.co.uk
"You can be a king or a street sweeper, but everybody dances with the grim reaper" - Robert Alton Harris
|
|
|
|
|
Try the JQuery focus(), it seems to work a little better. Fires the focus event...
$('#gameCanvas').focus();
|
|
|
|
|
Thanks I'm using .focus instead now, actually think its due to where I'm loading the script and how the Eventlistnerers are loaded, unfortunately lacked a lot of free time this week to experiment!
Simon Lee Shugar (Software Developer)
www.simonshugar.co.uk
"You can be a king or a street sweeper, but everybody dances with the grim reaper" - Robert Alton Harris
|
|
|
|
|
Not sure if this helps, noticed div had no var to represent the object before append, I like using css instead of the element attributes width and height.
var canvas = document.createElement("canvas");
var ctx = canvas.getContext("2d");
canvas.style.display = block;
canvas.style.width = 512;
canvas.style.height = 480;
canvas.id="gameCanvas";
var div = document.getElementById("slide-panel");
div.appendChild(canvas);
|
|
|
|
|
jkirkerx wrote: I like using css instead of the element attributes width and height.
jkirkerx wrote: canvas.style.width = 512;
canvas.style.height = 480;
Setting the width and height of a canvas control via CSS has negative impacts associated with it. You need to set height and width via the element attributes.
I agree however that in situations outside of the canvas element you would want to set these via CSS.
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
In my beginning, I used the width and height elements, but switched over to pure css later on in the years.
I know in HTML emails, I set both. I'll have to investigate the negative impacts because now I'm curious about it.
|
|
|
|
|
I think if you check the safari docs on canvas it even mentions there that you have to set the height and width via attributes.
when I wrote the jQuery plugin for http://dooscrib.com/[^] I had issues with coordinates not working if the height and width were set via CSS vs attribute.
since the canvas control came out of the camps of Apple I would trust their docs most.
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
Canvas must be a HTML 5 element, sorry if I sound dumb about it. I'm still using VS2010 because I don't own a licensed copy of Windows 7 for my VS 2012.
|
|
|
|
|
it is an HTML5 element.
jkirkerx wrote: sorry if I sound dumb about it
not dumb about it. I am just saving the frustration of having to learn about the pitfalls of doing the CSS route. I spent hours debugging my plugin trying to get the CSS route to work till I came across the apple docs for safari that clearly said to use the attributes.
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
Cheers for the input, still working on this, just lacking free time at all this week!
Anyway while debugging I tried throwing in the style, it didn't like style.display=block it decided not to draw the canvas!
Simon Lee Shugar (Software Developer)
www.simonshugar.co.uk
"You can be a king or a street sweeper, but everybody dances with the grim reaper" - Robert Alton Harris
|
|
|
|
|
Just as an idea, try setting the focus after the slide out animation has finished, rather than right when the slide element is clicked. If you are using the animate function in jQuery, I believe there is a "complete" function you can pass in that will execute once the animation is complete.
|
|
|
|
|
I've had a go, doing some experiment over the weekend I found it was actually the key EvenListeners not firing. My website's a little mashed togeather due to time constraints so I figured I was going to take a step back and see what javascript / Jquery is running and what I can cut back.
Simon Lee Shugar (Software Developer)
www.simonshugar.co.uk
"You can be a king or a street sweeper, but everybody dances with the grim reaper" - Robert Alton Harris
|
|
|
|
|
0
I am trying to achive a ause functionality in javascript.
I am making an asynchronous AJAX call and trying to achive synhronous functionality of AJAX. I want to pause the javascript until i receive the AJAX response for the asyn call of AJAX. Due to some reason i am not using the AJAX synchronous call which will solve my problem.
Once i make a call i use the following two functions to pause the JS
function pause2(numberMillis) {
var dialogScript = "window.setTimeout(" +
" function () { document.write(' '); window.close(); }, "
+ numberMillis + ");";
var result = window.showModalDialog('javascript.document.writeln(' +
'"' + dialogScript + '<' + '/script>")');
}
function pause3()
{
do
{
if(lmsCommitTimeOut<9000){
lmsCommitTimeOut=lmsCommitTimeOut+1000;
pause2(1000);
}
else
{
//alert("TimeOut");
lmsCommitStatus="false";
return;
}
}while(readStateAchived=="false")
}
I call the pause3(); function which internally calls the pause2(1000) for every 1sec until i get the ajax response back, which i check with the help of a js variable "readStateAchived".
This is working well in IE6, but in IE7 it is poping up the modal window and not getting closed, I have to close it manually.
Can anyone help me with this?
Thank you.
|
|
|
|
|
Hello,
Tyr using jquery blockUI (v2.31) plugin instead. Before your AJAX call just use
$.blockUI({ message: '<h1><img src="busy.gif" /> Just a moment...</h1>' }); . More help can be obtained from here[^].
Regards,
Prasad P. Khandekar
Knowledge exists, man only discovers it.
|
|
|
|
|
0
I am trying to achive a ause functionality in javascript.
I am making an asynchronous AJAX call and trying to achive synhronous functionality of AJAX. I want to pause the javascript until i receive the AJAX response for the asyn call of AJAX. Due to some reason i am not using the AJAX synchronous call which will solve my problem.
Once i make a call i use the following two functions to pause the JS
function pause2(numberMillis) {
var dialogScript = "window.setTimeout(" +
" function () { document.write(' '); window.close(); }, "
+ numberMillis + ");";
var result = window.showModalDialog('javascript.document.writeln(' +
'"<script>' + dialogScript + '<' + '/script>")');
}
function pause3()
{
do
{
if(lmsCommitTimeOut<9000){
lmsCommitTimeOut=lmsCommitTimeOut+1000;
pause2(1000);
}
else
{
//alert("TimeOut");
lmsCommitStatus="false";
return;
}
}while(readStateAchived=="false")
}
I call the pause3(); function which internally calls the pause2(1000) for every 1sec until i get the ajax response back, which i check with the help of a js variable "readStateAchived".
This is working well in IE6, but in IE7 it is poping up the modal window and not getting closed, I have to close it manually.
Can anyone help me with this?
Thank you.
|
|
|
|