使用 javascript 函数更新 ASP.Net 中的样式

发布于 2024-12-26 15:32:18 字数 3132 浏览 2 评论 0原文

好的,我有一个 Silverlight 4 应用程序,位于带有几个横幅的页面上。根据 Silverlight 应用程序中的某些变量,我需要显示其中一个横幅并重新定位 Silverlight 应用程序,使其与横幅底部对齐。为了实现这一目标,我一直在使用 HtmlPage.Window.Invoke("MethodToShowTheBannerIWant")。每个横幅都有其​​自己的功能,尝试显示正确的横幅并将应用程序定位为正确排列。 都

  function ShowFirstBanner() {
        FirstBannerStyle.style.display = 'block';
        SilverlightAppStyle.style.marginTop = '120px';
        SilverlightAppStyle.style.height = '495px';
    }

每个横幅看起来

   <table id="FirstBannerStyle"  style="position:absolute;top:0px;left:0px;display:none;height:50px;" width=100% border="0" cellpadding="0">
<tr> 
  <td><img src="http://www.bannerimageurl.jpg" usemap="#Map2" border="0"></td> </table>

像这样

  <map name="Map2"><area shape="poly" coords="763,19,769,91,985,92,981,69" href="http://www.xxxxxxx.com/cal.htm" target="_self" />
         <area shape="rect" coords="11,73,88,89" href="http://www.xxxxxxx.com/index.htm" target="_self">
         <area shape="rect" coords="121,70,186,88" href="http://www.xxxxxxx.com/courses.htm" target="_self">
         <area shape="rect" coords="217,70,327,90" href="http://www.xxxxxxx.com/ts.htm">
         <area shape="rect" coords="365,70,521,91" href="http://www.xxxxxxx.com/po.htm">
         <area shape="rect" coords="556,71,618,91" href="http://www.xxxxxxxx.com/au.htm" target="_self">
         <area shape="rect" coords="655,72,726,91" href="http://www.xxxxxxx.com/CU/index.htm" target="_self">
      </map>

,Silverlight 应用程序区域看起来像这样

  <form id="form1" runat="server" style="height:100%">
<div id="silverlightControlHost" style="height:100%;text-align:center">
    <object data="data:application/x-silverlight-2,"  type="application/x-silverlight-2" width="100%" height="100%">
      <param name="source" value="ClientBin/XXX.XXX.XXX.xap"/>
      <param name="onError" value="onSilverlightError" />
      <param name="background" value="white" />
      <param name="minRuntimeVersion" value="4.0.50826.0" />
      <param name="autoUpgrade" value="true" />
      <param name="InitParams" value=<%=System.Configuration.ConfigurationManager.AppSettings.GetValues(0).FirstOrDefault()%>/>
      <param name="windowless" value="true" />
      <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0" style="text-decoration:none">
          <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
      </a>
    </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>

 <div id="InvisibleFrame"></div>    
</form>        

我遇到的问题是这个过程在 IE8 中运行良好,但在 IE9 或 Firefox 中根本不起作用。当我的代码点击 HtmlPage.Window.Invoke("ShowFirstBanner") 时,它会卡在那里,永远不会越过该行,但不会显示任何错误消息,而是无限期地等待该命令完成。如果我用函数注释掉代码,它就会进行调用并正常继续。这与我如何更新 Firefox 和 IE9 不喜欢的样式有关。有人知道一种在所有浏览器中都适用的方法吗?

Okay so I have a Silverlight 4 app sitting on a page with a couple banners. Depending on some variables within the Silverlight app I need to show one of the banners and re-position the Silverlight app so that it lines up with the bottom of the banner. To accomplish this I have been using HtmlPage.Window.Invoke("MethodToShowTheBannerIWant"). Each banner has it's own function that attempts to show the correct banner and position the app to line up properly. Something like

  function ShowFirstBanner() {
        FirstBannerStyle.style.display = 'block';
        SilverlightAppStyle.style.marginTop = '120px';
        SilverlightAppStyle.style.height = '495px';
    }

Each banner looks like

   <table id="FirstBannerStyle"  style="position:absolute;top:0px;left:0px;display:none;height:50px;" width=100% border="0" cellpadding="0">
<tr> 
  <td><img src="http://www.bannerimageurl.jpg" usemap="#Map2" border="0"></td> </table>

with a map in the like this

  <map name="Map2"><area shape="poly" coords="763,19,769,91,985,92,981,69" href="http://www.xxxxxxx.com/cal.htm" target="_self" />
         <area shape="rect" coords="11,73,88,89" href="http://www.xxxxxxx.com/index.htm" target="_self">
         <area shape="rect" coords="121,70,186,88" href="http://www.xxxxxxx.com/courses.htm" target="_self">
         <area shape="rect" coords="217,70,327,90" href="http://www.xxxxxxx.com/ts.htm">
         <area shape="rect" coords="365,70,521,91" href="http://www.xxxxxxx.com/po.htm">
         <area shape="rect" coords="556,71,618,91" href="http://www.xxxxxxxx.com/au.htm" target="_self">
         <area shape="rect" coords="655,72,726,91" href="http://www.xxxxxxx.com/CU/index.htm" target="_self">
      </map>

and the Silverlight app area looks like this

  <form id="form1" runat="server" style="height:100%">
<div id="silverlightControlHost" style="height:100%;text-align:center">
    <object data="data:application/x-silverlight-2,"  type="application/x-silverlight-2" width="100%" height="100%">
      <param name="source" value="ClientBin/XXX.XXX.XXX.xap"/>
      <param name="onError" value="onSilverlightError" />
      <param name="background" value="white" />
      <param name="minRuntimeVersion" value="4.0.50826.0" />
      <param name="autoUpgrade" value="true" />
      <param name="InitParams" value=<%=System.Configuration.ConfigurationManager.AppSettings.GetValues(0).FirstOrDefault()%>/>
      <param name="windowless" value="true" />
      <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0" style="text-decoration:none">
          <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
      </a>
    </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>

 <div id="InvisibleFrame"></div>    
</form>        

The issue I am having is that this process works great in IE8, but doesn't work at all in IE9 or Firefox. When my code hits the HtmlPage.Window.Invoke("ShowFirstBanner") it gets stuck right there and never moves past that line, but does not display any error message and instead will just sit indefinitely waiting for that command to complete. If I comment out the code withing the function it makes the call and continues as normal. So something related to how I'm updating the styles Firefox and IE9 doesn't like. Anyone have an idea for a way to do this that will work in all browsers?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

演出会有结束 2025-01-02 15:32:18

JavaScript 中的“FirstBannerStyle”和“SilverlightAppStyle”在哪里定义?

您需要通过 ID 来获取元素:

document.getElementById('FirstBannerStyle').style.display = 'block';

或者如果您使用的是 jQuery:

$('FirstBannerStyle').show()

Where are "FirstBannerStyle" and "SilverlightAppStyle" defined in your JavaScript?

You need to grab the element by its ID:

document.getElementById('FirstBannerStyle').style.display = 'block';

or if you're using jQuery:

$('FirstBannerStyle').show()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文