English 中文(简体)
我怎么能够改变基于“ #”测试变量的图像的图谱?
原标题:How can I change the image url of an image based on #var=test variable?

I m 试图根据从pvar=1'(或2,或3,或4)的变数,在px asp.net c# page上改变形象

不幸的是,我不知道我刚才听到的那篇大事。 任何人能否把我放在一个以创新为基础的文字上,我可以尝试通过执行学习吗?

最佳回答

你的问题非常含糊,因此我肯定不清你需要什么...... 我只想写一些法典,看它是否接近标识

类似情况

<img id="someUniqueIdYouMakeUp">
<script type="text/javascript">
theImage = document.getElementById("someUniqueIdYouMakeUp");
if(window.location.hash == "#var=1")
{
  theImage.src = "/some/image.jpg";
}
else if(window.location.hash == "#var=2")
{
  theImage.src = "/some/other/image.jpg";
}
</script>

www.un.org/Depts/DGACM/index_spanish.htm 根据你的意见,你重新寻找图像,以更新,即使该页之后的散射变化。 为此,你需要制定类似于以下的法典:

var updateImageWhenHashChanges = function()
{
  theImage = document.getElementById("someUniqueIdYouMakeUp");
  if(window.location.hash == "#var=1")
  {
    theImage.src = "/some/image.jpg";
  }
  else if(window.location.hash == "#var=2")
  {
    theImage.src = "/some/other/image.jpg";
  }
  // Tell the window to call updateImageWhenHashChanges() again in 500 miliseconds:
  window.setTimeout(updateImageWhenHashChanges,500);
}
updateImageWhenHashChanges();

详情见window.settimeout

问题回答

不幸的是,答案与问题一样模糊。

显然,你想知道如何修改<代码>src的图像属性。

考虑到您的超文本中的这一形象:

<img id="myImage" src="someOldValue" />

你们可以使用这一javascript代码,使其形象得到其身份证的掌握,并改变rc的特性。

<script type="text/javascript">     

    document.getElementById( myImage ).src="someNewValue";

</script>

更正应在本文件印发之日后一星期内印发。

请注意,这是一个纯粹的 j解决办法。 如果你再次使用 j,根据你的实际情况,也许值得采取 j办法。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签