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

时间:2014-03-10 16:52:56

标签: 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 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>

4 个答案:

答案 0 :(得分:1)

只需使用window.open

var referenceToNewWindow = window.open(url, name, features);

答案 1 :(得分:0)

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>

答案 2 :(得分:0)

使用此

<a href="" onClick="return popitup('http://www.abc.com/youpage')">Click Me</a>

添加以下javascript脚本:

   <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>

答案 3 :(得分:0)

Stack Overflow这是一个例子。检查一下

javascript在下面

@ViewChild('inputValue',{static : false}) el:ElementRef; 
public searchChange(event) {    
      setTimeout(() => {  
        this.wildCardSearch = this.el.nativeElement.value
    }, 100)      
  }