java弹出网页代码,java弹出提示
JAVA中打开新页面代码
/**
目前创新互联已为近1000家的企业提供了网站建设、域名、网页空间、网站托管、服务器托管、企业网站设计、千阳网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
* 打开打印窗口
* url:链接页面或action动作
* Banglu
*/
function printWindow(url){
var sURL = url;
var sFeatures = "toolbar=no, menubar=no, scrollbars=no,resizable=yes, "
+ "location=no, status=no, titlebar=no, width=800, height=600, top=100, left=100";
window.open(sURL,'notoolbar',sFeatures);
}function exportWindow(url){
var sURL = url;
var sFeatures = "toolbar=no, menubar=no, scrollbars=no,resizable=yes, "
+ "location=no, status=no, titlebar=no, width=800, height=600, top=50, left=50";
var objwin=window.open(sURL,'export'+randomNum(),sFeatures);
objwin.close();
}
/**
* 打开模态窗口
* url:链接页面或action动作
* width:打开模态窗口的宽度
* height:打开模态窗口的高度
* 注意:打开模态窗口的页面中要在head后面加上
* meta http-equiv="Pragma" content="no-cache":禁止模态窗口缓存
* base target="_self"/:模态窗口中的表单在本窗口中提交
* a onClick='window.location = "view-source:" + window.location.href'b源文件/b/a 可以查看模态窗口的源文件
* Banglu
*/
function modalWindow(url, width, height){
var sURL = url;
var sFeatures = "dialogWidth:" + width + "px; dialogHeight:" + height + "px; "
+ "help:no; scroll:yes; center:yes; status:no;resizable:yes";
window.showModalDialog(sURL, window, sFeatures);
}/**
* 打开普通窗口
* url:链接页面或action动作
* width:宽度
* height:高度
* Banglu
*/
function openWindow(url, width, height){
var sURL=url;
var sFeatures = "scrollbars=yes, status=yes, resizable=yes,"
+ "toolbar=yes, menubar=yes, location=yes, titlebar=yes"
if(width!=null){
sFeatures+=", width="+width;
}
if(height!=null){
sFeatures+=", height="+height;
}
window.open(sURL, 'open'+randomNum(), sFeatures);
}/**
* 打开窗口
* url:链接页面或action动作
* width:宽度
* height:高度
Banglu
*/
function openNoBarWindow(url, width, height){
var sURL=url;
var sFeatures = "scrollbars=no, status=no, resizable=no,"
+ "toolbar=no, menubar=no, location=no, titlebar=no"
if(width!=null){
sFeatures+=", width="+width;
sFeatures+=", left="+(screen.width-width)/2;
}
if(height!=null){
sFeatures+=", height="+height;
sFeatures+=", top="+(screen.height-height-100)/2;
}
window.open(sURL, 'openNoBar'+randomNum(), sFeatures);
}
/**
* 打开全屏窗口
* url:链接页面或action动作
* Banglu
*/
function openFullWindow(url){
var sURL=url;
var sFeatures = "toolbar=no, menubar=no, scrollbars=no, resizable=yes, "
+ "location=no, status=no, titlebar=no, width="+(screen.width-10)+", "
+ "height="+(screen.height-60)+", top=0, left=0";
window.open(sURL, 'full'+randomNum(), sFeatures);
}/**
* 打开主窗口
* url:链接页面或action动作
* Banglu
*/
function openMainWindow(url){
var sURL=url;
var sFeatures = "toolbar=no, menubar=no, scrollbars=no, resizable=yes, "
+ "location=no, status=no,titlebar=no, width="+(screen.width-10)+", "
+ "height="+(screen.height-60)+", top=0, left=0";
window.open(sURL, 'main', sFeatures);
}
/**
* 设置链接
* url:连接的jsp页面或action动作
* Banglu
*/
function link(url, frameID){
if(frameID==null){
window.location.href = url;
}
else{
window.frames[frameID].location = url
}
}/**
* 回车代替tab
* Banglu
*/
function handleKey(){
var gk = window.event.keyCode;
if (gk==13) {
if(window.event.srcElement.tagName!='TEXTAREA'){
window.event.keyCode=9;
return;
}
}
}/**
* 全屏显示
* Banglu
*/
function fullScreen(){
window.dialogHeight=window.screen.availHeight;
window.dialogWidth=window.screen.availWidth;
}
function Resize_dialog(t,l,w,h) {
window.dialogTop = t+"px";
window.dialogLeft = l+"px";
window.dialogHeight = h+"px";
window.dialogWidth = w+"px";
}
求一段java代码,运行时可调用浏览器打开一个网页,网页地址在代码中即可
package com.test;
import java.lang.reflect.Method;
//实现打开浏览器并跳到指定网址的类
public class BareBonesBrowserLaunch {
public static void openURL(String url) {
try {
browse(url);
} catch (Exception e) {
}
}
private static void browse(String url) throws Exception {
//获取操作系统的名字
String osName = System.getProperty("os.name", "");
if (osName.startsWith("Mac OS")) {
//苹果的打开方式
Class fileMgr = Class.forName("com.apple.eio.FileManager");
Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] { String.class });
openURL.invoke(null, new Object[] { url });
} else if (osName.startsWith("Windows")) {
//windows的打开方式。
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
} else {
// Unix or Linux的打开方式
String[] browsers = { "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" };
String browser = null;
for (int count = 0; count browsers.length browser == null; count++)
//执行代码,在brower有值后跳出,
//这里是如果进程创建成功了,==0是表示正常结束。
if (Runtime.getRuntime().exec(new String[] { "which", browsers[count] }).waitFor() == 0)
browser = browsers[count];
if (browser == null)
throw new Exception("Could not find web browser");
else
//这个值在上面已经成功的得到了一个进程。
Runtime.getRuntime().exec(new String[] { browser, url });
}
}
}
//主方法 测试类
public static void main(String[] args) {
String url = "";
BareBonesBrowserLaunch.openURL(url);
}
朋友,觉得好的话,请采纳!你的鼓励是我学习的动力。
java弹出新窗口
定义一个按钮的OnClick事件
里面用写方法调用弹出窗口
代码
import java.awt.*;
import javax.swing.*;
import java.awt.Rectangle;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Frame1 extends JFrame
{
private JButton jButton1=new JButton();
public Frame1 ()
{
try {
jbInit();
}
catch(Exception exception) {
exception.printStackTrace();
}
this.setVisible(true);
}
private void jbInit () throws Exception
{
this.setBounds(300,180,400,300);
getContentPane().setLayout(null);
jButton1.setBounds(new Rectangle(127, 120, 139, 36));
jButton1.setMnemonic('C');
jButton1.setText("点我(C)");
jButton1.addActionListener(new ActionListener()
{
public void actionPerformed (ActionEvent e)
{
jButton1_actionPerformed(e);
}
});
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.getContentPane().add(jButton1);
}
public static void main (String[] args)
{
Frame1 frame1=new Frame1();
}
public void jButton1_actionPerformed (ActionEvent e)
{
this.setVisible(false);
JFrame jf1=new JFrame("子窗口");
jf1.setBounds(100,50,800,600);
jf1.setDefaultCloseOperation(jf1.EXIT_ON_CLOSE);
jf1.setVisible(true);
}
}
文章标题:java弹出网页代码,java弹出提示
本文来源:http://myzitong.com/article/hdscji.html