doudoulb1234 2015-08-13 13:01
浏览 28
已采纳

如何使用base-64源创建Image对象?

I have a remote web page, on which I use CURL and DOMDocument to retrive the src attribute of an image.

I use the following code, mixing JS in a PHP echo

<?php 

$toEcho = "";
$toEcho .= // some stuff here...
$toEcho.="
<script>

    //I create the object
    var img = new Image();

    //I set the source with the PHP variable : I get an error because of unexpected token ":"
    img.src = $imgsrc;

</script>"
echo $toEcho;
?>

I checked the source, it is valid, and displays properly in my browser(s).

Where could this come from ?

  • 写回答

1条回答 默认 最新

  • douer9399 2015-08-13 13:07
    关注

    Set the source like this:

    img.src = '$imgsrc';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 关于#qt#的问题:Qt代码的移植问题
  • ¥50 求图像处理的matlab方案
  • ¥50 winform中使用edge的Kiosk模式
  • ¥15 关于#python#的问题:功能监听网页
  • ¥15 怎么让wx群机器人发送音乐
  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化