不得不说UIWebView这个控件可定制、可获取的东西真的太少了。
找了半天,没找到相关的参数可以获取title的,只能是使用JavaScript了。代码如下:
- (void)webViewDidStartLoad:(UIWebView *)webView
{
NSString *theTitle=[webView stringByEvaluatingJavaScriptFromString:@"document.title"];
}不得不说UIWebView这个控件可定制、可获取的东西真的太少了。
找了半天,没找到相关的参数可以获取title的,只能是使用JavaScript了。代码如下:
- (void)webViewDidStartLoad:(UIWebView *)webView
{
NSString *theTitle=[webView stringByEvaluatingJavaScriptFromString:@"document.title"];
}没啥好说的,HTML中用Js获取一张图片的源地址有两种方式:
1、imgObj.src
2、imgObj.getAttribute(“src”);
区别是,当图片的源地址是相对地址时,方法一获取的是图片的绝对地址,方法二获取的还是相对地址。
谨作记录:)
Air允许您在程序中使用ActionScript 库(SWC 已编译文件)。同时也就意味着您可以在JavaScript AIR 程序中使用ActionScript 库以充分利用他们的优点和特性
要在JavaScript中使用SWC库您需要按以下步骤。
1、下载SWC格式的ActionScript库.您可以使用corelib.swc作为示例,然后重命后缀为zip(或其他存档格式,如RAR);
2、下一步,解压缩其中的library.swf(其实上一步可以不用重命名,只要打开方式选择WinRAR即可)
3、重命名为corelib.swf,然后把它放在项目文件夹下
最后,将以下代码放置在您的程序中以引入库
现在,您就可以引用库中的任何方法:
import com.adobe.utils.ArrayUtil;
var isEqual = new com.adobe.utils.ArrayUtil.arraysAreEqual(array1,array2)
Translated From:http://casario.blogs.com/mmworld/2008/12/using-actionscr.html
InfoQ上看到的:)
JavaScript多线程编程简介
前天写了一篇博文关于onload事件在FireFox和IE下的区别。(暂时不测试Opera,NetScape,Safari等浏览器)
再补充一下:
IE是在Document内容载入前即执行。
而FireFox是等待Document内容全部载入后再执行。
具体表现是,如果在onload中要获取某个element是取不到的,而FireFox却没有问题。
一种比较好的方法就是把 window.onload=onload();写到html的末尾。
或者设置一个定时器,大约3秒左右执行,但这个并不怎么保险:)
HTML真是高深莫测。
PS:最近公司.Net组人手紧缺,So,我又做老本行了。。。亲爱的Flex呀,啥时候才能回去呀?!
<body onload=”somfunc()”>
这个在IE下是没问题的,可在FireFox下就是不执行。
这个问题比较的细节。这样写,就会运行了。
<script type = “text/javascript” language =”javascript”>
document.body.onload = somfunc();
</script>
但是更好的方法是
document.body.onload=new Function(‘somfunc()’);
Attention:somfunc必须已经被实现。
哪位同学有空再加一个SilverLight的对比吧:)
让人很无语的WorkPress,用表格把这个页面都撑开了。用截图吧。。。
All tests were on the same system (2Ghz AMD Athlon XP2400+ Windows XP 1.5Gb RAM)
All times are in milliseconds
All tests were repeated multiple times on different days (after reboots) and on different systems to ensure that the results were consistent, but variation is inevitable. Try the tests on your own system.. and please report problems..
Flash tests (FP7,8,and 8.5) were loaded in IE6
Flash Players used: 7.0.19.0, 8.0.5.0, 8.5.0.133, 9.0.18.60
* indicates first run / second run of the same function
Run the Java version (prepared by Bill Riemers) of the test here (note.. it takes roughly 70 seconds for the applet to load the first time on my system. Results shown above are from reloading the page) The detailed result from running his benchmark on my system is here (yep.. I rounded some numbers.. we’re comparing 4649ms vs 6ms here)
Tests run on 11/24/06 used updated Flash SWF from Ted Patrick and used the released Flash Player 9. Some of the other tests (JS and FP7) were run again just to check that the results were still in line since they were run in the Fall of 2005. I didn’t rerun all of the JavaScript tests for IE6, and didn’t change the results because they were only off by a few miliseconds on most of them. I added the results for running JS in Opera.. and reran the Firefox tests since a new version was released.
Note that I did not run these test in the “stand alone” Flash Player. They’re run in the browser because that’s where almost all of my Flash code is executed. However, I’ve found in the past that code generally executes faster in the stand alone player.
1. JavaScript Speed test #3
2. JavaScript MD5 implementation
2. Flash implementation other JS tests were based (sometimes loosely) on some of these
Download sources:
HTML,
FLAs/SWFs (ActionScript 2)
MXML (original) * note that my MXML is quite crappy because I hadn’t even started learning ActionScript3 when I put this together..
MXML by Brian Deitte (strict typing made huge improvements over my original code)
MXML by Ted Patrick (note that all tests are run sequentially without unloading the SWF.. results vary greatly when I test multiple times)
Java by Bill Riemers
Copy From :http://oddhammer.com/actionscriptperformance/set4/
这个还是很有用的,特别是Flex对Flash Player的版本要求还是有那么点高的。
记录一下,呵呵:)
<script type=”text/javascript”>
function getFlashVer() {
var f=”";
var n=navigator;
if (n.plugins && n.plugins.length) {
for (var ii=0;ii<n.plugins.length;ii++) {
if (n.plugins[ii].name.indexOf(‘Shockwave Flash’)!=-1) {
f=n.plugins[ii].description.split(‘Shockwave Flash ‘)[1].split(‘ ‘)[0];
break;
}
}
} else if (window.ActiveXObject) {
for (var ii=10;ii>=2;ii–) {
try {
var fl=eval(“new ActiveXObject(‘ShockwaveFlash.ShockwaveFlash.”+ii+”‘);”);
if (fl) {f=ii + ‘.0′; break; }
}
catch(e) {}
}
}
document.write(“Flash Player version: <b>”+f+”</b>”);
}
getFlashVer();
</script>
以下讨论的技术只是防止用户使用PrintScreen键截屏。如果使用SnagIt估计没啥好办法了(如果是C/S程序估计可以写一个程序关闭它的进程,WS了点^_^)
首先讲一下思路吧。
方法一、捕获用户的KeyPress事件,如果捕获的按钮是PrintScreen。就把粘贴板的内容置空或者提示性内容。
但是貌似这个方法只在.Net WinForm中有效。.Net已经内置了Key.PrintScreen枚举。
其他语言貌似暂时不可行。因为找不到PrintScreen的ASCII码。。。
方法二、就是用一个计时器,不断地清空粘贴板或者填充提示性内容。但是这个方法不是非常好,会干扰用户操作。
不过网上我也找到了一种改善的方法。当然还会存在部分的干扰。特别是在JS下。
另外就是对于ActionScript。对键盘事件捕捉比较笨拙。所以以上方法极有可能无效。
以上只是设想而已哈:)