當前位置:首頁 » 編程語言 » java跳轉頁面

java跳轉頁面

發布時間: 2023-07-20 15:24:35

❶ 在java web開發中,凡是能實現頁面跳轉的方法有哪些具體列出這些方法的實現語句

一、跳轉到新頁面,並且是在新窗口中打開頁面:
function openHtml()
{
//do someghing here...
window.open("xxxx.html");
}
window是一個javascript對象,可以用它的open方法,需要注意的是,如果這個頁面不是一相相對路徑,那麼要加「http://」,比如:
function openHtml()
{
window.open("http://www..com");
}

二、在本頁面窗口中跳轉:
function totest2()
{
window.location.assign("test2.html");
}
如果直接使用location.assgin()也可以,但是window.location.assign()更合理一些,當前窗口的location對象的assign()方法。
另外,location對象還有一個方法replace()也可以做頁面跳轉,它跟assign()方法的區別在於:
replace() 方法不會在 History 對象中生成一個新的紀錄。當使用該方法時,新的 URL 將覆蓋 History 對象中的當前紀錄。

❷ java中如何做到界面的跳轉

假如有兩個frame,分別為frame1,frame2,frame1加個按鈕實現跳轉.frame1代碼如下
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;

public class frame1 extends JFrame implements ActionListener{

/**
* @param args
*/
private JButton jb;
public frame1()
{
this.setSize(300, 200);
this.setLocation(300, 400);
jb=new JButton("跳轉");
this.add(jb);
jb.addActionListener(this);//加入事件監聽
this.setVisible(true);

}
public static void main(String[] args) {
// TODO Auto-generated method stub
frame1 frame=new frame1();

}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==jb)
{
this.dispose();//點擊按鈕時frame1銷毀,new一個frame2
new frame2();
}
}

}

frame2是個單純的界面
import javax.swing.JButton;
import javax.swing.JFrame;

public class frame2 extends JFrame{

/**
* @param args
*/
public frame2()
{

this.setSize(300, 200);
this.setLocation(300, 400);

this.setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
frame2 frame=new frame2();
}

}

❸ java怎麼實現窗口跳轉

完整程序沒那個功夫,如果你說的是Swing開發的話,通常是在點擊按鈕的時候把當前窗口的對象傳遞給即將打開的子窗口,並在子窗口的onload事件中控制父窗口的顯示狀態。

熱點內容
淘寶密碼賬號在哪裡看 發布:2025-02-08 04:29:39 瀏覽:536
描繪四季的美文寫一份朗讀腳本 發布:2025-02-08 04:29:21 瀏覽:138
金蝶軟體伺服器是電腦嗎 發布:2025-02-08 04:27:06 瀏覽:973
linux如何搭建c編譯環境 發布:2025-02-08 04:24:49 瀏覽:819
ps腳本批量處理切圖 發布:2025-02-08 04:19:03 瀏覽:57
iisftp命令 發布:2025-02-08 04:04:39 瀏覽:455
安卓為什麼軟體老更新 發布:2025-02-08 03:53:40 瀏覽:735
演算法實際應用 發布:2025-02-08 03:53:07 瀏覽:535
c語言加密文本 發布:2025-02-08 03:47:50 瀏覽:681
安卓打字鍵盤的聲音在哪裡調 發布:2025-02-08 03:42:27 瀏覽:32