如何动态的给frame的src赋值

思路:1、动态,则首先需要截取URL的传参。

            2、将参数赋值给src

            3、页面加载就截取并绑定给frame


实现代码:

frame,取名为main

<frame src="" id="main" name="main" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto" target="_self" />


截取URL并赋值src,function为截取URL代码,$为页面加载就调用function并赋值src

name为参数名,如我的URL:http://localhost:30242/Backstage/index.aspx?url=FlightAttendant/ReCoor_all.aspx

<script type="text/javascript">
           function GetQueryString(name) {
               var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
               var r = window.location.search.substr(1).match(reg);
               if (r != null)
                   return unescape(r[2]);
               return null;
           }
           $(document).ready(function () {
               $("#main").attr("src", GetQueryString('url'));
           });

    </script>


在Java中,如果需要在一个线程中给窗体控件赋值,需要注意以下几点: 1. 窗体控件只能在创建它的线程中进行操作,如果在其他线程中直接修改窗体控件,程序会抛出异常。 2. 如果需要在其他线程中更新窗体控件的值,可以使用Java Swing提供的方法SwingUtilities.invokeLater()。该方法可以将更新控件的操作放到事件队列中,以便在Swing的事件调度线程中执行,从而避免多线程冲突。 下面是一个简单的示例代码,演示如何在Java中使用线程更新窗体控件的值: ``` import javax.swing.*; public class MainFrame extends JFrame { private JLabel label; public MainFrame() { label = new JLabel("Hello, world!"); add(label); setSize(200, 200); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } public void updateLabelText(final String text) { SwingUtilities.invokeLater(new Runnable() { public void run() { label.setText(text); } }); } } public class Main { public static void main(String[] args) { final MainFrame frame = new MainFrame(); new Thread(new Runnable() { public void run() { while (true) { frame.updateLabelText("Time: " + System.currentTimeMillis()); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } } }).start(); } } ``` 在这个示例代码中,我们创建了一个包含一个标签控件的窗体MainFram,然后创建了一个线程,每隔一秒钟更新标签的文本。在updateLabelText方法中,我们使用SwingUtilities.invokeLater方法将更新控件的操作放到事件队列中,从而避免多线程冲突。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值