Archives for the ‘Browsers’ Category

动态嵌入 javascript 和 css

Tuesday, February 26th, 2008

动态嵌入 css 代码

var headID = document.getElementsByTagName(“head”)[0];
var cssNode = document.createElement(‘link’);
cssNode.type = ‘text/css’;
cssNode.rel = ’stylesheet’;
cssNode.href = ‘FireFox.css’;
cssNode.media = ’screen’;
headID.appendChild(cssNode);

动态嵌入 javascript 代码

var headID = document.getElementsByTagName(“head”)[0];
var newScript = document.createElement(’script’);
newScript.type = ‘text/javascript’;
newScript.src = ‘http://www.somedomain.com/somescript.js’;
headID.appendChild(newScript);

Ajax 就加入 javascript

function ajaxObject(url, callbackFunction) {

var that=this;

this.updating = false;

this.update = function(passData,postMethod) {

if (that.updating==true) { return false; }

that.updating=true;

var AJAX = null;

if (window.XMLHttpRequest) {

AJAX=new XMLHttpRequest();

} else {

AJAX=new ActiveXObject(“Microsoft.XMLHTTP”);

}

if (AJAX==null) {

return false;

} else {

AJAX.onreadystatechange = function() {

if (AJAX.readyState==4) {

that.updating=false;

that.callback(AJAX.responseText,AJAX.status,AJAX.responseXML);

delete AJAX;

}

}

var timestamp = new Date();

if (postMethod==’POST’) {

var uri=urlCall+’?'+timestamp.getTime();

AJAX.open(“POST”, uri, true);

AJAX.setRequestHeader(“Content-type”, “application/x-www-form-urlencoded”);

AJAX.send(passData);

} else {

var uri=urlCall+’?'+passData+’&timestamp=’+(timestamp*1);

AJAX.open(“GET”, uri, true);

AJAX.send(null);

}

return true;

}

}

var urlCall = url;

this.callback = callbackFunction || function () { };

}

function attachScript(responseText, responseStatus) {

// This function is called by the ajaxObject when the server has finished

// sending us the requested script.

if (responseStatus==200) {

eval(responseText);

}

}

// ajaxObject is an object constructor, pass it the server url you want it to call

// and the function name you want it to call when it gets the data back from the server.

// Use the .update() method to actually start the communication with the server.

// The first optional argument for update is the data you want to send to the server.

// ajaxvar.update(‘id=1234&greed=good&finish=true’);

// The second optional argument for update is ‘POST’ if you want to send the data

// as a POST instead of the default GET (post can handle larger amounts of data and

// the data doesn’t show up in your server logs).

// ajaxvar.update(‘id=1234&greed=good&finish=true’,'POST’);

var getScriptViaAjax=new ajaxObject(‘http://mydomain.com/somescript.js’,attachScript);

getScriptViaAjax.update();

var anotherScript = new ajaxObject(‘http://mydomain.com/anotherScript.php’,attachScript);

anotherScript.update(‘userId=4323′,’POST’);

flickr tag ajax 搜索

<script type=”text/javascript”>

function jsonFlickrFeed(feed){

z=”;

for (x=0; x<feed.items.length; x++) {

tmp=feed.items[x].media.m;

tmp=tmp.replace(/_m\.jpg/g,’_s.jpg’);

z+=’<img src=”‘+tmp+’” mce_src=”‘+tmp+’” alt=”some img” width=”75px” height=”75px” style=”margin: 2px;”>’;

}

document.getElementById(‘pics’).style.display=’block’;

document.getElementById(‘pics’).innerHTML=z;

}

function searchFlickr() {

var headID = document.getElementsByTagName(“head”)[0];

var newScript = document.createElement(’script’);

tagID = escape(document.getElementById(‘tags’).value);

document.getElementById(‘tags’).value=”;

newScript.type = ‘text/javascript’;

newScript.src = ‘http://flickr.com/services/feeds/photos_public.gne?tags=’ + tagID + ‘&format=json’;

headID.appendChild(newScript);

document.getElementById(‘pics’).style.display=’block’;

document.getElementById(‘pics’).innerHTML=”Loading…”;

return false;

}

</script>

<form action = “#” onsubmit=”return searchFlickr();”>

<input type=’text’ size=’40′ id=’tags’>   <input type=’submit’>

</form>

<div style=’border: 1px solid black; width: 100%; display: none;’ id=’pics’></div>

via http://www.hunlock.com/blogs/Howto_Dynamically_Insert_Javascript_And_CSS

firefox css bug

Tuesday, January 22nd, 2008

firefox background-position bottom bug

当背景图片大于页面时,firefox background-position bottom 显示有bug,不是浏览器的左下角而是当前页面可见元素的左下角。

设置 html {height:100%} 后解决问题(也可以 body {height:100%,但有时候不行})。还有把设置 100%(或者其他百分比)的说法,但似乎不行。

运行代码 [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]

运行代码 [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]

firefox 控制 legend 也有bug! 这样
这里是legend

来控制。

http://www.tyssendesign.com.au/articles/css/legends-of-style/

label 也有bug,firefox 基本上对 label 的样式表不能正确处理,哪怕是

label#labelid #other 这样的样式也不能识别!

firefox 框架大小的控制代码

Monday, January 21st, 2008

firefox 中不能象 ie 那样直接 top.AAA.cols=”…” 来修改框架宽度,而必须 document.getElementById(“aa”).setAttribute(“cols”,”…”)

显示更多

firefox2.0里的书签全部丢失

Thursday, January 17th, 2008

上次碰到这个问题是几年前了,firefox上辛辛苦苦建立的标签目录一夜之间全部消失,那一次导致我转向了opera,并焊在上面长达两年之久。这回再次出现同样的问题,真是令人沮丧。

估计是非正常关机造成的xml配置文件损坏,不知大家有没有类似经验。

JQuery tabs标签页 代码

Thursday, January 17th, 2008

显示更多

via http://stilbuero.de/jquery/tabs_3/

网页解密练习

Tuesday, January 1st, 2008

貌似这个 中国第八军团安全竞赛网络版 只有四关?有点旧,但还有点意思,一般的右键之类肯定是关掉的。思路如下:

第一关:就是个 unescape,直接在 firefox ctrl+A 选择全部,右键查看 view selection source 就能看到密码;

第二关:unescape 里面还有个