2013-06-29 32 views
0

SCRIPT如何彈出窗口附加到頁面

<SCRIPT TYPE="text/javascript"> 
    <!-- 
    function popup(mylink, windowname) 
    { 
     if (! window.focus)return true; 
     var href; 
     if (typeof(mylink) == 'string') 
      href=mylink; 
     else 
     href=acc_like; 
     window.open(href, windowname, 'width=400,height=200,scrollbars=yes'); 
     return false; 
    } 
    //--> 
</SCRIPT> 

HTML

<BODY onLoad="popup('autopopup.html', 'ad')"> 

我收到彈出窗口,但我不希望它儘量減少當用戶點擊了外它。

+2

如果你想擁有它的靜態網站上的,比你不應該創建一個新窗口。您可以將其嵌入您現有的窗口 –

+0

示例?請 – Johan

+0

它是可能的,沒有任何代碼或知道您的網站。也許你想要在iframe中打開新的html文件。 –

回答

1

在我看來,你應該使用jquery dialog得到你想要的,下面的示例(試試jsFiddle)什麼:

<!DOCTYPE html> 

<html> 
<head> 
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" /> 

    <script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
    <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script> 
    <script type="text/javascript"> 
     $(document).ready(function() { 
      $("#dialog-form").dialog({ 
       modal: true <!-- is background page responsive or not --> 
      }); 
     }); 
    </script> 
</head> 
<body>  
    Background information 
    <div id="dialog-form" title="Hello">Basic information</div> 
</body> 
</html> 
相關問題