You can not do this in Internet Explorer. For it to work, you must remove the div tags!
<div><script>document.body.appendChild(document.createElement('script'))</script></div>
May you be able to in IE8
Friday, February 29, 2008
Thursday, February 21, 2008
get the text
this code will alert the selected text
if (window.getSelection) {
var str = window.getSelection();
}
else if (document.getSelection) {
var str = document.getSelection();
} else if (document.selection && document.selection.createRange) {
var range = document.selection.createRange();
var str = range.text;
} else {
var str = "Sorry, this is not possible with your browser.";
}
alert(str);
part of this code is from
this site
I added some code to make it work for safari
if (window.getSelection) {
var str = window.getSelection();
}
else if (document.getSelection) {
var str = document.getSelection();
} else if (document.selection && document.selection.createRange) {
var range = document.selection.createRange();
var str = range.text;
} else {
var str = "Sorry, this is not possible with your browser.";
}
alert(str);
part of this code is from
this site
I added some code to make it work for safari
Wednesday, February 20, 2008
Monday, February 18, 2008
Saturday, February 16, 2008
Adding Scripts to others' web pages: a few thoughts
There could be problems doing things like document.body.appendChild when there DOM hasn't loaded yet.
Therefore you need to do things to watchout for that
< body onload = "customfunction()" >
or put script tags right before body
or window.onload =
or window.attachevent("onload",customfunction)
window.addeventlistener("load",customfunction,false) //or true I dont know
What about large images etc. that you dont want to wait for
another thing to research is the defer attribute of the script tag
another thing to research is the DOMContentLoaded
http://developer.mozilla.org/en/docs/Gecko-Specific_DOM_Events
"Fired on a Window object when a document's DOM content is finished loaded, but unlike "load", does not wait till all images are loaded. Used for example by GreaseMonkey to sneak in to alter pages before they are displayed. "
what about document.write
http://www.hedgerwow.com/360/dhtml/ie-dom-ondocumentready.html
unobtrusive javaScript
Therefore you need to do things to watchout for that
< body onload = "customfunction()" >
or put script tags right before body
or window.onload =
or window.attachevent("onload",customfunction)
window.addeventlistener("load",customfunction,false) //or true I dont know
What about large images etc. that you dont want to wait for
another thing to research is the defer attribute of the script tag
another thing to research is the DOMContentLoaded
http://developer.mozilla.org/en/docs/Gecko-Specific_DOM_Events
"Fired on a Window object when a document's DOM content is finished loaded, but unlike "load", does not wait till all images are loaded. Used for example by GreaseMonkey to sneak in to alter pages before they are displayed. "
what about document.write
http://www.hedgerwow.com/360/dhtml/ie-dom-ondocumentready.html
unobtrusive javaScript
Friday, February 15, 2008
Monday, February 11, 2008
Flash Ball example slow in some cases
The ball example that I did is slow in IE7 on my windows vista.
When I open the swf in the browser on IE and on Safari it is also slow.
In Firefox,opera,safari it is fast when embedded in a page.
When I open the swf in the browser on firefox 2, it starts fast and then goes slow.
In opera when It is embedded in a page it is fast, and when I open it in a browser it is also fast!
When I open the swf in the browser on IE and on Safari it is also slow.
In Firefox,opera,safari it is fast when embedded in a page.
When I open the swf in the browser on firefox 2, it starts fast and then goes slow.
In opera when It is embedded in a page it is fast, and when I open it in a browser it is also fast!
Actionscript and flex language reference online
What's the difference between this http://livedocs.adobe.com/flex/201/langref/index.html and this http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/
Sunday, February 10, 2008
Actionscript 3.0 Timer and key events
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.text.TextField;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class BM2 extends Sprite
{
public var txtbox:TextField;
public var kDown:JS;
public var kUp:JS;
public var xx:int;
public var yy:int;
public var rep:Timer;
public var ymov:int;
public var xmov:int;
public function BM2()
{
kDown = new JS();
kUp = new JS();
txtbox = new TextField();
txtbox.text = "Hello World";
addChild(txtbox);
stage.addEventListener(KeyboardEvent.KEY_DOWN,keydownhandler);
stage.addEventListener(KeyboardEvent.KEY_UP,keyuphandler);
kDown[37] = function():void{xmov = -1;};
kDown[38] = function():void{ymov = -1;};
kDown[39] = function():void{xmov = 1;};
kDown[40] = function():void{ymov = 1;};
kUp[37] = function():void{xmov = 0;};
kUp[38] = function():void{ymov = 0;};
kUp[39] = function():void{xmov = 0;};
kUp[40] = function():void{ymov = 0;};
rep = new Timer(1,0);
rep.addEventListener(TimerEvent.TIMER, draw);
rep.start();
}
public function test(event:TimerEvent):void{txtbox.text = event.toString();}
public function draw(event:TimerEvent):void
{
xx = xx + 1 * xmov;
yy = yy + 1 * ymov;
graphics.clear();
graphics.lineStyle(1);
graphics.beginFill(0xFF8000);
graphics.drawCircle(xx, yy, 10);
}
public function keydownhandler(evento:KeyboardEvent):void
{
txtbox.text = evento.keyCode.toString() + " " + kDown[evento.keyCode];
if (evento.keyCode >= 37 && evento.keyCode <= 40) kDown[evento.keyCode]();
}
public function keyuphandler(evento:KeyboardEvent):void
{
txtbox.text = evento.keyCode.toString() + " " + kUp[evento.keyCode];
if (evento.keyCode >= 37 && evento.keyCode <= 40) kUp[evento.keyCode]();
}
}
} //end package
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Point;
import flash.geom.Rectangle;
//this is how i am rescuing the coolness of javascripts objects!!
dynamic class JS
{
public function JS(){}
}
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.text.TextField;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class BM2 extends Sprite
{
public var txtbox:TextField;
public var kDown:JS;
public var kUp:JS;
public var xx:int;
public var yy:int;
public var rep:Timer;
public var ymov:int;
public var xmov:int;
public function BM2()
{
kDown = new JS();
kUp = new JS();
txtbox = new TextField();
txtbox.text = "Hello World";
addChild(txtbox);
stage.addEventListener(KeyboardEvent.KEY_DOWN,keydownhandler);
stage.addEventListener(KeyboardEvent.KEY_UP,keyuphandler);
kDown[37] = function():void{xmov = -1;};
kDown[38] = function():void{ymov = -1;};
kDown[39] = function():void{xmov = 1;};
kDown[40] = function():void{ymov = 1;};
kUp[37] = function():void{xmov = 0;};
kUp[38] = function():void{ymov = 0;};
kUp[39] = function():void{xmov = 0;};
kUp[40] = function():void{ymov = 0;};
rep = new Timer(1,0);
rep.addEventListener(TimerEvent.TIMER, draw);
rep.start();
}
public function test(event:TimerEvent):void{txtbox.text = event.toString();}
public function draw(event:TimerEvent):void
{
xx = xx + 1 * xmov;
yy = yy + 1 * ymov;
graphics.clear();
graphics.lineStyle(1);
graphics.beginFill(0xFF8000);
graphics.drawCircle(xx, yy, 10);
}
public function keydownhandler(evento:KeyboardEvent):void
{
txtbox.text = evento.keyCode.toString() + " " + kDown[evento.keyCode];
if (evento.keyCode >= 37 && evento.keyCode <= 40) kDown[evento.keyCode]();
}
public function keyuphandler(evento:KeyboardEvent):void
{
txtbox.text = evento.keyCode.toString() + " " + kUp[evento.keyCode];
if (evento.keyCode >= 37 && evento.keyCode <= 40) kUp[evento.keyCode]();
}
}
} //end package
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Point;
import flash.geom.Rectangle;
//this is how i am rescuing the coolness of javascripts objects!!
dynamic class JS
{
public function JS(){}
}
Thursday, February 7, 2008
Making videos
I have a really cool camera from Canon. It is a camera for pictures but it also records videos. It is a Canon PowerShot SD750 7.1 Megapixels
I love it. I bought a 4 Gig SD card for it and the SD card fits right into my laptop to upload my videos.
Making small movies is great on it because you don't have to mess with the MINI DV tapes, and the quality of video is pretty good!
Apple's iMovie is great for doing video.
It has drawbacks but Windows Movie Maker is allright for simple stuff.
I love it. I bought a 4 Gig SD card for it and the SD card fits right into my laptop to upload my videos.
Making small movies is great on it because you don't have to mess with the MINI DV tapes, and the quality of video is pretty good!
Apple's iMovie is great for doing video.
It has drawbacks but Windows Movie Maker is allright for simple stuff.
Tuesday, February 5, 2008
Publishing Factor
You think your done, until your printer doesn't work and your other computer doesn't have openoffice.
You think your done until you can't find your firewire cord.
You think your done until you can't find your firewire cord.
Subscribe to:
Posts (Atom)