顯示具有 Javascript 標籤的文章。 顯示所有文章
顯示具有 Javascript 標籤的文章。 顯示所有文章

2013年8月21日 星期三

竹取JS網頁直書

  1. 下載taketori_js.zip
  2. 使用範例
    <html>
    <body>
    <div class="tategaki">
    <!--內文放在這裡-->
    </div>
    <a href="#" id="toggle">直書橫書切換</a>
    <script type="text/javascript" src="taketori.js" charset="UTF-8"></script>
    <script type="text/javascript">
    //<![CDATA[
    var taketori = (new Taketori()).set({fontFamily:'sans-serif'}).element('div.tategaki').toVertical();
    taketori.document.element('toggle').addEventListener('click',function (e) {
     taketori.toggleAll();
     taketori.document.stopPropagation(e);
     taketori.document.preventDefault(e);
     return false;
    });
    //]]>
    </script>
    

2013年8月20日 星期二

開新視窗






<html>
 <body>
  <form>
 
   <input onclick="window.open('http://www.google.com','mywindow','width=400,height=200,toolbar=yes, location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes, resizable=yes')" type="button" value="New Window!" /> 
  </form>
</body>
</html>

2012年10月15日 星期一

js convert int to ascii character

[string to int ]
String.charCodeAt() can convert string characters to ASCII numbers. 
For example:
"ABC".charCodeAt(0) // returns 65

[int to string]
String.fromCharCode(10)

2012年10月10日 星期三

js load google into an iframe

Reference
Google and Facebook are using a X-Frame-Options in the HTTP response header to avoid the content being loaded in a iFrame.

The X-Frame-Options HTTP response header can be used to indicate whether or not a browser should be allowed to render a page in a or . Sites can use this to avoid clickjacking attacks, by ensuring that their content is not embedded into other sites.


Source: Mozilla Developer Network - The X-Frame-Options response header

I don't think it is possible for you to override this setting.

Solution


  1. Browse to google page.
  2. Save the Google web page.
  3. Remove the X-Frame-Options tag.
  4. Now, You can load the modified google web page into an iframe.

js encode a url string

Reference
Check out the built-in function encodeURIComponent(str) and encodeURI(str). In your case, this should work:

var myOtherUrl = "http://example.com/index.html?url=" + encodeURIComponent(myUrl);

2012年10月8日 星期一

js uncheck all radio boxes

2012年10月3日 星期三

js get string length

var str="";
document.write(str.length);

js define the type of a function's parameter

You cannot define the type of the parameter. The parameter has to check when it is used in a function.
function myFunction(myDate, myString) {
  if(arguments.length > 1 && typeof(Date.parse(myDate)) == "number" && typeof(myString) == "string") {
    //Code here
  }
}

2012年9月25日 星期二

js substring test

js switch test

js set checkbox unchecked

js find an item in an array

js get which element invoke the event

js on page load complete, do something

js div set inner html

2012年9月24日 星期一

c# run a batch file

using System.Diagnostics;

private static void Run(string args)
        {
            Process proc = new Process();

            proc.StartInfo.FileName = args;
            proc.StartInfo.Arguments = "";
            proc.StartInfo.WorkingDirectory = Application.StartupPath;
            // Redirect the output stream of the child process.
            proc.StartInfo.UseShellExecute = false;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            proc.Start();
            // Do not wait for the child process to exit before
            // reading to the end of its redirected stream.
            // p.WaitForExit();
            // Read the output stream first and then wait.
            string output = proc.StandardOutput.ReadToEnd();
            Console.WriteLine(output);
            proc.WaitForExit();
            int exitCode = proc.ExitCode;
            Console.WriteLine("Exit code: " + exitCode);
            proc.Close();
        }

2011年1月25日 星期二

Google chrome播放音樂

Google chrome版本8.0.522不支援wav音樂檔案播放,但支援mp3音樂檔案。
程式碼
<html>
<title>程式印象</title>
<head>

<script>
function EvalSound(soundobj) {
  document.getElementById("sound").innerHTML="<embed src='"+soundobj+"' hidden=true autostart=true loop=false>"; 
}
</script>
</head>
<body>
<center>
<div id="sound"></div>
<form>
<input type="button" value="Play Sound" onClick="EvalSound('button-10.mp3')">
</form>
此Javascript由<a href="http://programfeelings.blogspot.com/">程式印象</a>提供
</center>
</body>
</html>

2011年1月14日 星期五

Javascript混淆器

網路工具
Packer,能壓縮編碼

PS:check功能,程式碼在ie無法執行,在chrome中則可以。
javascriptcompressor,能壓縮編碼

PS:與Packer功能相同。
Dojo Toolkit JavaScript Compressor
PS:執行shrink em!出現錯誤,訊息:An error has been encountered.。

軟體
digua ,需安裝JRE。
YUI compressor,java指令。