English 中文(简体)
未知显示含有jpeg形象的javascript binary 方言
原标题:HTML syntax unknown to display a javascript binary string containing a jpeg image

我可以回避这一问题,尽管它必须只是一个非常小的同yn问题,正如你所看到的那样: 事实上,我只找一小 piece子,除非我打算做些什么是不可能做的(因为我看不出为什么不能做)。

我写了一份功能,把图像输入服务器方面的基地64,因为我想把许多图像储存成一个阵列:

因此,有基地64 我可以下载图像,作为我可以组织成阵的普通星座,然后在我选择正确形象和正确时刻时,把图像放在物体上,而不必再次提及服务器,以便用户不必等待。

然后,我做这样的事情:

  • 第一阶段:

    function download64(imageUrl) //->string { // ask the server to send the imageUrl as a base64 string var tx = DoTheJob(); // ...connect through ajax and download the image converted in base64 as a string in var tx return tx }

At this stage, I m holding the image in the tx Base64-string on client side. Somewhat later I want to display my image in the div called "cadre", so I do the following:

  • Second phase: I just have to call the "display64" function to set my image into the "cadre" div-object on the screen:

    显示64(");

利用这一职能:

function display64(destinationDiv,imgText64)    //->void
{  // display  imgText64    into destinationDiv
  var oImg = "<img alt=   src= data:image/jpg;base64," + imgText64 + " >";
  var x = document.getElementById(destinationDiv);
  x.innerHTML = oImg;       
}

现在形象就显示。 不幸的是,这只好与第纳尔多,因为因特网探索者8能够读到基地64的图像超过32Kb! 在我的主人中,我们只使用第8号电线!

然后,我放弃了我的基地64,决定把图像作为双向扼杀,我可以管理这种形象,尽管我最初曾有过一面 n。

现在,我在这里说的是我的双轨迹,其中载有来源JPG文件的确切副本(包括我编码的零件,然后在客户方面恢复过来)。 因此,我现在需要的是简单的功能显示Bin ,但我可以发现网上的星号:

function displayBin(destinationDiv,imgTextBin) //->void
{  // display  imgTextBin  into destinationDiv  
   var oImg = "<img alt=   src= ??????? + imgTextBin + " >"; // What s the syntax here, please? 
   var x = document.getElementById(destinationDiv);
   x.innerHTML = oImg;  
}

谁能帮助? 感谢很多。

问题回答

如果我理解你的问题,你想要储存图像,那么你就不必与服务器连接。 这样做的一种方法是预先载录如下图象:var img=new Value; img.src= path ;。 你可以把所有图像装入一个阵列,然后可以在必要时添加这些图像。 这里在图像前装上有很多东西,因为似乎你想要完成什么。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

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 ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签