如何使用onclick在javascript中打开弹出窗口?

如何使用onclick在javascript中打开弹出窗口?,javascript,Javascript,如何使用JavaScript中带有按钮的onclick方法显示下面的弹出窗口 <div data-role="popup" id="myPopupDialog4"> <a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a> <div

如何使用JavaScript中带有按钮的
onclick
方法显示下面的弹出窗口

 <div data-role="popup" id="myPopupDialog4">
    <a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a>

    <div data-role="header">
       <h4>Post Update </h4>
    </div>

    <div data-role="main" class="ui-content">
             <pre><B>
             <div id="resultDayOfWeek"></div>
             <div id="resultNum"></div>
             <div id="resultDir"></div>
             <div id="resultStop"></div>
             <div id="resultTime"></div>     
             </B> 
             </pre>
    <fieldset data-role="controlgroup">
        <legend>Choose Status</legend>

       <label for="Arrived/Left">Arrived/Left</label>
       <input type="radio" name="status" id="Arrived/Left" value="Arrived/Left">
       <label for="Delayed">Delayed</label>
       <input type="radio" name="status" id="Delayed" value="Delayed">  
       <label for="Canceled">Canceled</label>
       <input type="radio" name="status" id="Canceled" value="Canceled">
       <label for="getupdate">getupdate from others</label>
       <input type="radio" name="status" id="getupdate" value="getupdate">
       <label for="Other">Other</label>
       <input type="radio" name="status" id="Other" value="Other">
       </fieldset>

       <textarea name="addinfo" id="info"> Comments goes here.... </textarea>
       <input type="submit"  value="Submit" onclick="postSubmit();">  
       <div id="poststatus"></div>   
    </div>  

    <div data-role="footer" >
       <h1>Footer Text</h1>
    </div>

 </div>
function popup(mylink, windowname, w, h){
    if (! window.focus)return true;
    var href;
    if (typeof(mylink) == 'string')
       href=mylink;
    else
       href=mylink.href;
    window.open(href, windowname, "width="+w+",height="+h+",scrollbars=yes,toolbar=no" );
    return false;
}

 <a href="http://www.example.com"  onClick="return popup(this, 'Title', '400', '500')">Link</a>

function popup(mylink, windowname, w, h){
    if (! window.focus)return true;
    var href;
    if (typeof(mylink) == 'string')
       href=mylink;
    else
       href=mylink.href;
    window.open(href, windowname, "width="+w+",height="+h+",scrollbars=yes,toolbar=no" );
    return false;
}

 <a href="http://www.example.com"  onClick="return popup(this, 'Title', '400', '500')">Link</a>
更新后 选择状态 到达/离开 延迟 取消 从其他人处获取更新 其他 这里有评论。。。。 页脚文本
功能弹出窗口(mylink、windowname、w、h){
function popup(mylink, windowname, w, h){
    if (! window.focus)return true;
    var href;
    if (typeof(mylink) == 'string')
       href=mylink;
    else
       href=mylink.href;
    window.open(href, windowname, "width="+w+",height="+h+",scrollbars=yes,toolbar=no" );
    return false;
}

 <a href="http://www.example.com"  onClick="return popup(this, 'Title', '400', '500')">Link</a>
如果(!window.focus)返回true; var href; if(typeof(mylink)=‘string’) href=mylink; 其他的 href=mylink.href; window.open(href,windowname,“width=“+w+”,height=“+h+”,滚动条=是,工具栏=否); 返回false; }
只需使用:

function popup(mylink, windowname, w, h){
    if (! window.focus)return true;
    var href;
    if (typeof(mylink) == 'string')
       href=mylink;
    else
       href=mylink.href;
    window.open(href, windowname, "width="+w+",height="+h+",scrollbars=yes,toolbar=no" );
    return false;
}

 <a href="http://www.example.com"  onClick="return popup(this, 'Title', '400', '500')">Link</a>
用这个

function popup(mylink, windowname, w, h){
    if (! window.focus)return true;
    var href;
    if (typeof(mylink) == 'string')
       href=mylink;
    else
       href=mylink.href;
    window.open(href, windowname, "width="+w+",height="+h+",scrollbars=yes,toolbar=no" );
    return false;
}

 <a href="http://www.example.com"  onClick="return popup(this, 'Title', '400', '500')">Link</a>
   <script>
   function popitup(url) 
   {
    newwindow=window.open(url,'name','height=300,width=650,screenX=400,screenY=350');
    if (window.focus) {newwindow.focus()}
    return false;
   }
   </script>

function popup(mylink, windowname, w, h){
    if (! window.focus)return true;
    var href;
    if (typeof(mylink) == 'string')
       href=mylink;
    else
       href=mylink.href;
    window.open(href, windowname, "width="+w+",height="+h+",scrollbars=yes,toolbar=no" );
    return false;
}

 <a href="http://www.example.com"  onClick="return popup(this, 'Title', '400', '500')">Link</a>
function popup(mylink, windowname, w, h){
    if (! window.focus)return true;
    var href;
    if (typeof(mylink) == 'string')
       href=mylink;
    else
       href=mylink.href;
    window.open(href, windowname, "width="+w+",height="+h+",scrollbars=yes,toolbar=no" );
    return false;
}

 <a href="http://www.example.com"  onClick="return popup(this, 'Title', '400', '500')">Link</a>
添加以下javascript脚本:

function popup(mylink, windowname, w, h){
    if (! window.focus)return true;
    var href;
    if (typeof(mylink) == 'string')
       href=mylink;
    else
       href=mylink.href;
    window.open(href, windowname, "width="+w+",height="+h+",scrollbars=yes,toolbar=no" );
    return false;
}

 <a href="http://www.example.com"  onClick="return popup(this, 'Title', '400', '500')">Link</a>
<script>
        function openPopup() {
            document.getElementById("boxPopup").style.display = "block";
        }

        function closePopup() {
            document.getElementById("boxPopup").style.display = "none";
        }
        // When the user clicks anywhere outside of the modal, close it
        window.onclick = function (event) {
            var modal = document.getElementById('boxPopup');
            if (event.target == modal) {
                closePopup();
            }
        }

    </script>

function popup(mylink, windowname, w, h){
    if (! window.focus)return true;
    var href;
    if (typeof(mylink) == 'string')
       href=mylink;
    else
       href=mylink.href;
    window.open(href, windowname, "width="+w+",height="+h+",scrollbars=yes,toolbar=no" );
    return false;
}

 <a href="http://www.example.com"  onClick="return popup(this, 'Title', '400', '500')">Link</a>
函数popitup(url) { newwindow=window.open(url,'name','height=300,width=650,screenX=400,screenY=350'); if(window.focus){newwindow.focus()} 返回false; }
这里有一个例子。检查这个

function popup(mylink, windowname, w, h){
    if (! window.focus)return true;
    var href;
    if (typeof(mylink) == 'string')
       href=mylink;
    else
       href=mylink.href;
    window.open(href, windowname, "width="+w+",height="+h+",scrollbars=yes,toolbar=no" );
    return false;
}

 <a href="http://www.example.com"  onClick="return popup(this, 'Title', '400', '500')">Link</a>
下面是javascript

function popup(mylink, windowname, w, h){
    if (! window.focus)return true;
    var href;
    if (typeof(mylink) == 'string')
       href=mylink;
    else
       href=mylink.href;
    window.open(href, windowname, "width="+w+",height="+h+",scrollbars=yes,toolbar=no" );
    return false;
}

 <a href="http://www.example.com"  onClick="return popup(this, 'Title', '400', '500')">Link</a>

function popup(mylink, windowname, w, h){
    if (! window.focus)return true;
    var href;
    if (typeof(mylink) == 'string')
       href=mylink;
    else
       href=mylink.href;
    window.open(href, windowname, "width="+w+",height="+h+",scrollbars=yes,toolbar=no" );
    return false;
}

 <a href="http://www.example.com"  onClick="return popup(this, 'Title', '400', '500')">Link</a>
函数openPopup(){ document.getElementById(“boxPopup”).style.display=“block”; } 函数closePopup(){ document.getElementById(“boxPopup”).style.display=“无”; } //当用户单击模式之外的任何位置时,将其关闭 window.onclick=函数(事件){ var modal=document.getElementById('boxPopup'); 如果(event.target==模态){ closePopup(); } }
弹出窗口定义在哪里?为什么在标题中提到jQuery,但在帖子中要求使用JavaScript?您根本不需要jQuery来完成这项工作。
function popup(mylink, windowname, w, h){
    if (! window.focus)return true;
    var href;
    if (typeof(mylink) == 'string')
       href=mylink;
    else
       href=mylink.href;
    window.open(href, windowname, "width="+w+",height="+h+",scrollbars=yes,toolbar=no" );
    return false;
}

 <a href="http://www.example.com"  onClick="return popup(this, 'Title', '400', '500')">Link</a>