|
There are a ton of examples but I would certainly recommend using jquery[^]
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
By using Json() method we can send data to webmethod from the javascript.
|
|
|
|
|
org.mozilla.javascript.EcmaError: ReferenceError: "ActiveXObject" is not defined
Friends have encountered this kind of problem, I use ie8, Internet options security Settings for this part set I set, no, can you tell me how to solve? Please specify, thank you!
|
|
|
|
|
Say what?
Simple. You have a website that uses an ActiveX object. When you view this on your computer it is okay, you use IE8.
When your friends try to view it using FF, they get a message that says ActiveXObject isn't defined.
You wanna know why?
Easy, only (that's only, only, only or ONLY) Mirosoft Internet Explorer supports them.
There are precisely 2 options in this case:
1) Avoid using an ActiveXObject.
2) Force your friends to use IE.
I'll leave it to you to decide which is the least unpalatable..
(99%+ of the rest of the world went with option 1 btw)
Make it work. Then do it better - Andrei Straut
|
|
|
|
|
I got a problem with arrays in js and I'm starting to lose it.
Every iteration generates a different value.
However, it appears that it pushes the same value in the entire row; so the entire row has the same "random" value every time.
I want to have every 'x' to have a "random" value.
for (var x = 0; x <= 90; x++) {
var col = CustomRandom();
memBlock[x, 68] = Math.floor(col.next() * 255);
}
The "2D" Array is created with a recursive function I found on the web:
function createMemblock(length) {
var a = new Array(length || 0);
if (arguments.length > 1) {
var args = Array.prototype.slice(arguments, 1);
for (var i = 0; i < length; i++) {
a[i] = createMemblock.apply(this, args);
}
}
return a;
}
And here is the entire script, just in case:
window.requestAnimFrame = (function (callback) {
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function (callback) {
window.setTimeout(callback, 1000 / 60);
};
})();
function createMemblock(length) {
var a = new Array(length || 0);
if (arguments.length > 1) {
var args = Array.prototype.slice(arguments, 1);
for (var i = 0; i < length; i++) {
a[i] = createMemblock.apply(this, args);
}
}
return a;
}
var CustomRandom = function (nseed) {
var seed, constant = Math.pow(2, 13) + 1, prime = 1987,
maximum = 1000;
if (nseed) {
seed = nseed;
}
if (seed == null) {
seed = (new Date()).getTime();
}
return {
next: function (min, max) {
seed *= constant;
seed += prime;
return min && max ? min + seed % maximum / maximum * (max - min) : seed % maximum / maximum;
}
}
}
function getColor(R, G, B) {
var s = "#";
if (R <= 15) {
s += "0";
}
s += R.toString(16);
if (G <= 15) {
s += "0";
}
s += G.toString(15);
if (B <= 15) {
s += "0";
}
s += B.toString(15);
return s;
}
function animate() {
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
for (var y = 0; y <= 67; y++) {
for (var x = 1; x <= 89; x++) {
memBlock[x, y] = (memBlock[x - 1, y + 1] + memBlock[x + 1, y + 1]) / 2;
}
}
for (var x = 0; x <= 90; x++) {
var col = CustomRandom();
memBlock[x, 68] = Math.floor(col.next() * 255);
}
for (var y = 0; y <= 68; y++) {
for (var x = 0; x <= 90; x++) {
context.fillStyle = getColor(memBlock[x, y], 0, 0);
context.fillRect(x * 10, y * 10-10, 10, 10);
}
}
requestAnimFrame(function () {
animate();
});
}
function InitMemblock() {
for (var x = 0; x <= 90; x++) {
for (var y = 0; y <= 68; y++) {
memBlock[x, y] = 0;
}
}
}
window.onload = function () {
InitMemblock();
animate();
};
var memBlock = createMemblock(90, 68);
It's just an experiment with the canvas API; but If I can't control a 2D-block of memory I pretty much can't do anything.
If I can't get it to work I suppose I could use a single Array; but that would really suck.
Giraffes are not real.
|
|
|
|
|
It's not so tricky to create a 2d array, you just need to go about it a little differently to some other langs. First, you want to create the first dimension. Next, you need to fill each element in this dimension with a second array.
In my case, I've abstracted a screen. The first dimension is the rows, or y-coord. Each of these rows contains an array that holds all of the pixels in that line - the columns.
This code simply creates a 320x200 array and fills it with a simple xor pattern.
Of course, the other way to do it is to do what the compiler does - simply allocate a block of memory and then index into it yourself. The imageData object of the canvas does this - it has a 1d array that represents the pixels. So (y*width*4)+(x*4) will give you the index of the pixel you want. Since it's a 32bit pixel, there's 4 bytes for each one. It saves indexing and is much quicker and easy enough enough.
That said, here's the code I promised earlier.
var screenArray;
function mInit()
{
var x, y, width=320, height=200;
var result = new Array;
for (y=0; y<height; y++)
{
result[y] = new Array;
for (x=0; x<width; x++)
{
result[y][x] = x^y;
}
}
screenArray = result;
console.log(screenArray);
}
Make it work. Then do it better - Andrei Straut
|
|
|
|
|
Dear all,
Now, I'm implementing flexigrid table using jquery, for server side script I use PHP. I've made it and run properly, but there is no clear button to reset grid table after do searching. What should I do ? So I can reset grid table after searching ? I use library flexigrid.pack.js from http://www.flexigrid.info
Thank you,
|
|
|
|
|
hello
i would appreciate a little help here
is it possible to make default pagination of my dynamic html table created from saving form elements
i need to make 15 records per page and i tried lots of plugins but i couldn't get it done
thanks
Mille
my code is:
var Animals ={
index: window.localStorage.getItem("Animals:index"),
$table: document.getElementById("animals-table"),
$form: document.getElementById("animals-form"),
$button_save: document.getElementById("animals-save"),
$button_discard: document.getElementById("animals-discard"),
init: function() {
if (!Animals.index) {
window.localStorage.setItem("Animals:index", Animals.index = 1);
}
Animals.$form.reset();
Animals.$button_discard.addEventListener("click", function(event) {
Animals.$form.reset();
Animals.$form.id_entry.value = 0;
}, true);
Animals.$form.addEventListener("submit", function(event) {
var entry = {
id: parseInt(this.id_entry.value,radix),
animal_id:this.animal_id.value,
animal_name: this.animal_name.value,
animal_type: this.animal_type.value,
bday: this.bday.value,
animal_sex: this.animal_sex.value,
mother_name: this.mother_name.value,
farm_name: this.farm_name.value,
money: this.money.value,
weight: this.weight.value,
purchase_partner: this.purchase_partner.value
};
if (entry.id === 0) {
Animals.storeAdd(entry);
Animals.tableAdd(entry);
}
else { // edit
Animals.storeEdit(entry);
Animals.tableEdit(entry);
}
this.reset();
this.id_entry.value = 0;
event.preventDefault();
}, true);
if (window.localStorage.length - 1) {
var animals_list = [], i, key;
for (i = 0; i < window.localStorage.length; i++) {
key = window.localStorage.key(i);
if (/Animals:\d+/.test(key)) {
animals_list.push(JSON.parse(window.localStorage.getItem(key)));
}
}
if (animals_list.length) {
animals_list.sort(function(a, b)
{return a.id < b.id ? -1 : (a.id > b.id ? 1 : 0);})
.forEach(Animals.tableAdd);}
}
Animals.$table.addEventListener("click", function(event) {
var op = event.target.getAttribute("data-op");
if (/edit|remove/.test(op)) {
var entry = JSON.parse(window.localStorage.getItem("Animals:"+ event.target.getAttribute("data-id")));
if (op == "edit") {
Animals.$form.id_entry.value = entry.id;
Animals.$form.animal_id.value = entry.animal_id;
Animals.$form.animal_name.value = entry.animal_name;
Animals.$form.animal_type.value = entry.animal_type;
Animals.$form.bday.value = entry.bday;
Animals.$form.animal_sex.value = entry.animal_sex;
Animals.$form.mother_name.value = entry.mother_name;
Animals.$form.farm_name.value = entry.farm_name;
Animals.$form.money.value = entry.money;
Animals.$form.weight.value = entry.weight;
Animals.$form.purchase_partner.value = entry.purchase_partner;
}
else if (op == "remove") {
if (confirm('Are you sure you want to remove this animal from your list?' )) {
Animals.storeRemove(entry);
Animals.tableRemove(entry);
}
}
event.preventDefault();
}
}, true);
},
storeAdd: function(entry) {
entry.id = Animals.index;
window.localStorage.setItem("Animals:index", ++Animals.index);
window.localStorage.setItem("Animals:"+ entry.id, JSON.stringify(entry));
},
storeEdit: function(entry) {
window.localStorage.setItem("Animals:"+ entry.id, JSON.stringify(entry));
},
storeRemove: function(entry) {
window.localStorage.removeItem("Animals:"+ entry.id);
},
tableAdd: function(entry) {
var $tr = document.createElement("tr"), $td, key;
for (key in entry) {
if (entry.hasOwnProperty(key)) {
$td = document.createElement("td");
$td.appendChild(document.createTextNode(entry[key]));
$tr.appendChild($td);
}
}
$td = document.createElement("td");
$td.innerHTML = 'Edit | Remove';
$tr.appendChild($td);
$tr.setAttribute("id", "entry-"+ entry.id);
Animals.$table.appendChild($tr);
},
tableEdit: function(entry) {
var $tr = document.getElementById("entry-"+ entry.id), $td, key;
$tr.innerHTML = "";
for (key in entry) {
if (entry.hasOwnProperty(key)) {
$td = document.createElement("td");
$td.appendChild(document.createTextNode(entry[key]));
$tr.appendChild($td);
}
}
$td = document.createElement("td");
$td.innerHTML = 'Edit | Remove';
$tr.appendChild($td);
},
tableRemove: function(entry) {
Animals.$table.removeChild(document.getElementById("entry-"+ entry.id));
}
};
Animals.init();
</script>
|
|
|
|
|
Hi all
i have this java script that with Firefox works fine but with IE9 don't work; any idea how to solve the problem ? Thanks in advance.
here the javascript
var element = e.srcElement || e.target;
if(element != null){
if(element.tagName == "INPUT") {
//alert("Before: " + element.getAttribute("type"));
element.setAttribute("type", "password");
//alert("After: " + element.getAttribute("type"));
}
}
|
|
|
|
|
hi,
I have reviewed yr code , can u check method compatibility with i9.
may be some problem in this code ..."var element = e.srcElement || e.target;"
|
|
|
|
|
you press F12 in IE9, or go to tools I think, and select developer for F12, and you can run it again, and it will flag the error for you.
What is e?, I don't see a reference to that object.
|
|
|
|
|
create an INPUT
IE 8
createElement('') // don't forget < and >
Opera, Mozilla ....
createElement('INPUT')
...
pointerOfInput.type=....
example onkey handler
function som(e) // e placeholder for event
{
var KeyCodeValue;
if( (e==null) || (e==undefined)){e=window.event;}
if('which' in e){KeyCodeValue=e.which;}
else{KeyCodeValue=e.keyCode;}
....
}
example mouseevent handler
function som(e) // e placeholder for event
{
if( (e==null) || (e==undefined)){e=window.event;}
var LeftPos=e.clientX;
var TopPos=e.clientY;
...
}
|
|
|
|
|
Hi everyone,
I am using a html frameset in my project. When i try to open a html file inside a frame using window.open("htmlfile","frameName"),its not opening the file inside the frame. I am facing this issue in google chrome only. Can anyone please suggest me how to open a html file inside a frame in google chrome.
Greetings,
Virgi...
|
|
|
|
|
Chrome uses network path.
e.g. local document with iframe file:///F:/test/test.html
to test an document with iframe (IFRAME-tag) use a http server (not local).
may be chrome has an option to turn off this rule.
window.open("htmlfile","frameName") is not an iframe or frame
but what is the path of "htmlfile" ?
check path
iframe is an html document with small javascript interface to parent.
iframe is a single document with own rights (a frame with rights like a pure html document).
I use on ma websides only nested documents ---> IFRAMEs and parent pointer in javascript.
To overlay an document with other document use IFRAME, e.g. transparent background if IFRAME.
example for an IFRAME document
<doctype html="">
eval(parent.decode_javascript_of_iframe());
test(); // init of iframe AFTER decode above
This kind of using an iframe is like using of an "app". It is possilbe to create metro look
like win 8 in use of some iframes. Or iframes can us same place on parent document
(one iframe runs at a every moment).
IFRAME needs some ressources of browser ! Opera is fast. Chrome too. Mozilla is slow.
Only Opera can manage IFRAMEs fast.
On my webside www.twseiten.com you see iframe: See running mouse on top, put a mouseover this mouse
and IFRAME addons bar is visible (on off).
On this webside you find informations for apache http server in windows.
|
|
|
|
|
just copy and paste in browser and test hope you will find your answer
function test() {
document.getElementById("iframe").src = "http://asp.net";
}
</script>
</head>
<body>
<input type="submit" onclick="test()" value="using javascript">
<iframe name="InlineFrame1" id="iframe" style="position:absolute;left:79px;top:118px;width:602px;height:337px;z-index ;" src="" frameborder="0">Your browser does not support inline frames or is currently configured not to display inline frames.</iframe>
<div id="wb_Text1" style="position:absolute;left:101px;top:70px;width:250px;height:16px;z-index:1;">
<span style="color:#000000;font-family:Arial;font-size:13px;"><a href="http://www.lipsum.com" target="InlineFrame1">using html</a></span></div></pre></pre>
|
|
|
|
|
I want to Validate The FileUpload control from Client Side using Javascript. I am not able to Upload more than 4 MB in all the upload controls in the gridview. Please let me know is there any Solution for this.....
|
|
|
|
|
Member 7910360 wrote: all the upload controls in the gridview
I dont know what does it mean.
Anyway, you cant upload more than 4mb is a server issue. Server doesn't allow more than 4mb. It is changeable.
To validate file: all you have to in onchnage action do your validation. if validation success then start uploading otherwise cancel selection by clearing the selected path
I wish I could believe there is an after life.
|
|
|
|
|
u have to do with c# code. It will help u to validate the uploading item size
Kavit Trivedi
|
|
|
|
|
Hi,
In firefox, and chrome, I have a progress bar when someone uploads a file, however the same code doesn't work in IE (surprise surprise), it fails on:
var file = this.files[0];
My question is how do I do the equivalent for IE? Pointing me to the documentation would best.
code is:
function uploadImage(){
$('#percent').progressbar({
value: 0
});
$( "#dialog" ).dialog({
resizable: false,
height:150,
modal: true,
buttons: {
Cancel: function() {
if (xhr){
xhr.abort();
xhr = null;
}
$( this ).dialog( "close" );
}
}
});
document.getElementById('photo').addEventListener('change', function(e) {
var file = this.files[0];
var formdata = new FormData();
formdata.append('file', file);
xhr = new XMLHttpRequest();
xhr.file = file;
xhr.addEventListener('progress', function(e) {
var done = e.position || e.loaded, total = e.totalSize || e.total;
$('#percent').progressbar('value', (Math.floor(done/total*1000)/10));
}, false);
if ( xhr.upload ) {
xhr.upload.onprogress = function(e) {
var done = e.position || e.loaded, total = e.totalSize || e.total;
$('#percent').progressbar('value', (Math.floor(done/total*1000)/10));
};
}
xhr.onreadystatechange = function(e) {
if ( 4 == this.readyState ) {
console.log(this);
$('#src').val(this.responseText);
$('#dialog').dialog('close');
xhr = null;
}
};
xhr.open('post', '/index/fileupload', true);
xhr.send(formdata);
}, false);
}
|
|
|
|
|
try to find a file object or collection for IE at http://msdn.microsoft.com/en-us/library/ms533050.aspx
|
|
|
|
|
Hi,
came acoss this bit of code & don't fully understand it:
Value <<= 1
as in if((Value <<= 1) <= 255).......
I know << is equivalent to XOR but does this mean:
Value = Value << 1
if(Value <= 255)...
or something else???
Also:
value1 ^= value2....
is this equivalent to:
value1 = value1 ^ value2
Some of these short cuts get me and do you think I can find out about <<=...try googling that.
Any help appreciated
|
|
|
|
|
<< means bitshift left
>> is bitshift right
^ is XOR.
and a <operator>= b is the same as:
a = a <operator> b
|
|
|
|
|
“Object doesn't support property or method 'ready'”
I am getting this error while using custom dropdown list with js mootools slider. I have downloaded js slider and custom dropdown and while trying to merge it, I am facing this error.
I have downloaded js slider plugin from here:
http://landofcoder.com/index.php?option=com_jdownloads&Itemid=372&task=view.download&cid=6
Code of index page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Lof SliderNews 1.0 - Mootool 1.1</title>
<link rel="stylesheet" type="text/css" href="css/layout.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script language="javascript" type="text/javascript" src="js/mootools.svn.js"></script>
<script language="javascript" type="text/javascript" src="js/lofslidernews.mt11.js"></script>
<!-- DropDown -->
<link rel="stylesheet" type="text/css" href="msdropdown/dd.css" />
<script type="text/javascript" src="msdropdown/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="msdropdown/js/jquery.dd.js"></script>
<!-- DropDown -->
<style type="text/css">
/** css for override **/
/* move the main wapper to the right side */
.lof-snleft .lof-main-wapper
{
margin-left: auto;
margin-right: inherit;
clear: both;
height: 300px;
}
/* move the navigator to the left side */
.lof-snleft .lof-navigator-outer
{
left: 0;
top: 0;
right: inherit;
}
.lof-snleft .lof-navigator .active
{
background: url(images/arrow-bg2.gif) center right no-repeat;
}
.lof-snleft .lof-navigator li div
{
margin-left: inherit;
margin-right: 18px;
}
.lof-snleft .lof-navigator li.active div
{
margin-left: inherit;
margin-right: 18px;
background: url(images/grad-bg2.gif);
}
</style>
<script language="javascript" type="text/javascript">
jQuery.noConflict();
$(document).ready(function () {
$("#websites2").msDropDown({ mainCSS: 'dd2' });
});
</script>
</head>
<body>
<div id="container">
<h1>
<strong>Lof SliderNews 1.0</strong> - Mootool 1.1</h1>
<p>
<strong>Direction: Up to Down - Navitagor on the left side .</strong> The plugin
allow to use the wheelup and wheeldown to previous|next item in the list
</p>
<!------------------------------------- THE CONTENT ------------------------------------------------->
<div id="lofslidecontent45" class="lof-slidecontent lof-snleft">
<div class="preload">
<div>
</div>
</div>
<!-- MAIN CONTENT -->
<div class="lof-main-wapper">
<div class="lof-main-item">
<select name="websites2" id="websites2" style="width: 258px;">
<option value="msDropDown">One</option>
<option value="PrototypeCombobox">Prototype Combobox</option>
<option value="jQuery Tabs">jQuery Tabs</option>
<option value="Common Accordion">Common Accordion</option>
</select><br />
</div>
<div class="lof-main-item">
Page2
</div>
<div class="lof-main-item">
Page3
</div>
<div class="lof-main-item">
Page4
</div>
<div class="lof-main-item">
Page5
</div>
<div class="lof-main-item">
Page6
</div>-->
</div>
<!-- END MAIN CONTENT -->
<!-- NAVIGATOR -->
<div class="lof-navigator-outer">
<ul class="lof-navigator">
<li>
<div>
<img src="images/lofthumbs/791902news3.jpg" />
<h3>
NewsFlash 1
</h3>
<span>20.01.2010</span> - In id, mauris viverra asperiores, bibendum in id. Eu molestie.
Ac sit eu...
</div>
</li>
<li>
<div>
<img src="images/lofthumbs/435576news10.jpg" />
<h3>
NewsFlash 2
</h3>
<span>20.01.2010</span> -In id, mauris viverra asperiores, bibendum in id. Eu molestie.
Ac sit eu. ..
</div>
</li>
<li>
<div>
<img src="images/lofthumbs/641906img1.jpg" />
<h3>
NewsFlash 3
</h3>
<span>20.01.2010</span> - In id, mauris viverra asperiores, bibendum in id. Eu molestie.
Ac sit eu. ..
</div>
</li>
<li>
<div>
<img src="images/lofthumbs/416719news7.jpg" />
<h3>
NewsFlash 4</h3>
<span>20.01.2010</span> - In id, mauris viverra asperiores, bibendum in id. Eu molestie.
Ac sit eu. ..
</div>
</li>
<li>
<div>
<img src="images/lofthumbs/641906img1.jpg" />
<h3>
NewsFlash 5</h3>
<span>20.01.2010</span> -In id, mauris viverra asperiores, bibendum in id. Eu molestie.
Ac sit eu. ..
</div>
</li>
<li>
<div>
<img src="images/lofthumbs/416719news7.jpg" />
<h3>
NewsFlash 6</h3>
<span>20.01.2010</span> - In id, mauris viverra asperiores, bibendum in id. Eu molestie.
Ac sit eu. ..
</div>
</li>
</ul>
</div>
</div>
<script type="text/javascript">
jQuery.noConflict();
var _lofmain = $('lofslidecontent45');
var _lofscmain = _lofmain.getElement('.lof-main-wapper');
var _lofnavigator = _lofmain.getElement('.lof-navigator-outer .lof-navigator');
var object = new LofFlashContent(_lofscmain,
_lofnavigator,
_lofmain.getElement('.lof-navigator-outer'),
{ fxObject: { transition: Fx.Transitions.Quad.easeInOut, duration: 800 },
interval: 3000,
direction: 'vrdown'
});
object.start(true, _lofmain.getElement('.preload'));
</script>
</div>
</body>
</html>
Please reply ASAP.
Thanks.
|
|
|
|
|
You've used jQuery.noConflict() and then tried to access jQuery using the $() function. If you use noConflict, you have to use the full jQuery() function instead of $() - see here for details: http://api.jquery.com/jQuery.noConflict/[^]
|
|
|
|
|
Tried TypeScript? I've been playing around with it for a few days and I'm not sure what I think of it. It's almost javascript, but you get some benefits by using types and maybe a easier syntax.
I installed Mads Kristensen's Web Essentials 1.3 and of course the official plug-in for Visual Studio
Web Essentials crashes from time to time, but Mads is working on it
Do you have any experiences using TypeScript? Maybe some examples to share? How do you solve using libraries like jQuery(ui), knockout, underscore etc? It's really boring to write all these typescript interfaces. Typescripts homepage should have a directory for interfaces for the most used js-libraries (or maybe such directory exists somewhere?)
--------------------
When Chuck Norris' dreams come true, your worst nightmares begin.
|
|
|
|
|