Pages

Subscribe Twitter Twitter

Monday, May 22, 2006

javascript simulated query string

function getRequest(requestName) 
{ 
     var url=location.search.toLowerCase(); 
     var Request = new Object(); 

     if(url.indexOf("?")!=-1){ 
          var str=url.substr(1);
          strs = str.split("&"); 
          for(var i=0;i<strs.length;i++){    
               Request[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
          }    
     } 
     return(Request[requestName]); 

} 

javascript return value to opener

if (window.opener && !window.opener.closed)  
    window.opener.document.Form1.fileName.value ="aaa"; 

Tuesday, May 16, 2006

Export file from web page (JSP)

<%@page contentType="text/html;charset=MS950"%>
<%@page pageEncoding="MS950"%>
<%
    String m_filename = "hello.txt ";
    String m_content = "Hello\nWorld";
    response.addHeader("Content-Disposition", "attachment; filename=" + m_filename);
    response.setContentType("text/plain"); 
    response.getWriter().write(m_content);
%>

Monday, May 15, 2006

prevent right click(Javascript)

var message="Function Disabled!";

function clickIE4(){
  if (event.button==2){
  //alert(message);
  return false;
}
}

function clickNS4(e){
  if (document.layersdocument.getElementById&&!document.all){
     if (e.which==2e.which==3){
    //alert(message); return false; } } }
if (document.layers){
 document.captureEvents(Event.MOUSEDOWN);
 document.onmousedown=clickNS4; }
 else if (document.all&&!document.getElementById){
  document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("return false")

Thursday, May 11, 2006

How to add audio file in HTML img tag?

Add audio file in your img tag, such that your picture can sing.
It is funny.