我使用loadData方法将一些html内容加载到webview中,但是遇到类似这样的东西:
<a href="http://www.anywebsite.fr/">some text</a><img src="http://www.anotherwebsite.fr/thewantedpicture" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />
我只在应用程序中得到这个:
一些文本
如果我没有弄错,这还应该显示图片?如果有人有任何领导,谢谢......
在 html 中,我有很多带有名称(是的,名称,而不是 ID)的 DIV,分别是 p001、p002、p003...,它们是这样的:
<div id="pole" name="p001"><img src=""></div>
<div id="pole" name="p002"><img src=""></div>
<div id="pole" name="p003"><img src=""></div>
Run Code Online (Sandbox Code Playgroud)
等等...
在 Javascript 中,我定义了一个名为“pos”的变量,它包含一个数字,现在:“284”和一个应该将 img src 更改为“player.png”的函数。我尝试了两种方法,但这些方法都不起作用:
document.getElementsByName('p'+pos).innerHTML='<img src="player.png">';
Run Code Online (Sandbox Code Playgroud)
和
document.getElementsByName('p'+pos).getElementsByTagName("img").src="player.png";
Run Code Online (Sandbox Code Playgroud)
如何更改指定DIV中的img src?
我正在寻找一种方法来从文本中更改我所有的 img src。
例子 :
$var = "Some text Some text Some text <img src=\"test1.jpg\"/> Some text Some text Some text Some text <img src=\"test2.jpg\"/>";
Run Code Online (Sandbox Code Playgroud)
我想将两个 src 更改为数组中的一个值:
$array = array("apple.jpg", "banana.jpg");
Run Code Online (Sandbox Code Playgroud)
然后 $var 应该是这样的:
"Some text Some text Some text <img src=\"apple.jpg\"/> Some text Some text Some text Some text <img src=\"banana.jpg\"/>"
Run Code Online (Sandbox Code Playgroud)
我正在使用 img 的 src 对每个 preg_match 进行循环,但我不知道如何修改最终 var 中的 src。
(对不起我的英语不好 :( )
谢谢。
编辑 :
非常感谢您的回答
如果那样,我该怎么办,我只想修改以“数据如:src =“数据等”开头的 src
我很抱歉这个问题很容易,但我在src文件夹中创建新包时遇到了麻烦.如果有人可以帮助我,这将是太棒了.
在我的应用程序中,我将 YouTube 视频加载到 iframe 中。我已经清理了网址。但是当我运行应用程序时,src 属性不会加载。
下面是html:
<a [href]="data.url" target="_blank" *ngIf="data.contentTypeString=='YOUTUBE_VIDEO' && data.url != null">
<div class="embed-responsive embed-responsive-16by9">
<iframe *ngIf="data.contentTypeString=='YOUTUBE_VIDEO'"
class="embed-responsive-item"
src="{{data.url}}"></iframe>
</div>
</a>
Run Code Online (Sandbox Code Playgroud)
src 只是不会加载我尝试过的 [src]=data.url。
以下是我用来清理网址的方法:
public manageYoutubeUrl(url: any) {
console.log("url====" + url);
var youtubeUrl = this.sanitize.bypassSecurityTrustUrl(url.replace('watch?v=', 'embed/').replace('http://', 'https://')+"?wmode=opaque&rel=0&autohide=1&showinfo=0&wmode=transparent");
console.log("youtubeUrl=====" + youtubeUrl);
return youtubeUrl;
}
Run Code Online (Sandbox Code Playgroud)
当我检查 youtubeURL 日志时,它是这样的:
youtubeUrl=====SafeValue 必须使用 [property]=绑定: https://www.youtube.com/embed/l-103taCWOQ ?wmode=opaque&rel=0&autohide=1&showinfo=0&wmode= transparent (请参阅http://g. co/ng/security#xss )
错误错误:需要安全的 ResourceURL,在 DomSanitizerImpl.checkNotSafeValue 处获取了 URL(请参阅 http://g.co/ng/security#xss)(
请指导。谢谢。
我有一个页面,其中有一个使用以下代码的 iframe。
<iframe name="SL" src="https://sl.se/sv/" width="100%" height="870px"></iframe>
Run Code Online (Sandbox Code Playgroud)
它一直工作没有任何问题,但昨天它在 iframe 中变成了一个空白页面。我没有更新页面中的任何内容,因此它必须是 iframe src 中的某些内容由于某种原因而阻塞。有没有另一种方法可以让这个页面像 iframe 一样显示在里面,但有一些其他的代码?
当我将 prop 传递给 img 的属性 src 时,我遇到了链接未加载图像的问题。我尝试过将 require() 包裹在我的链接周围,但它不起作用。
我有一个巨大的产品库,使用图像加载器手动导入图像是不可行的。
因此,有没有办法使用 src 属性内的 props 来加载图像?
我正在使用 NODE_PATH=src/
谢谢您的帮助!
export const productLib = [{
ID: "001",
name:"product name",
src: "lib/productLib/img/product_name",
color: "",
...
}, {...}]Run Code Online (Sandbox Code Playgroud)
import React from 'react';
export class Products extends React.Component {
render() {
return(
<div className="products">
<img src={this.props.product.src} width="50" />
<h6>{this.props.product.name}<span className={`block ${this.props.product.color}`}></span></h6>
</div>
)
}
}Run Code Online (Sandbox Code Playgroud)
下面是我的车把页面和文件结构的图像,我无法使用这些车把加载任何图像,不确定是什么原因造成的:
<div>
<h1>HI</h1>
<img src="images/normal.gif">
</div>
Run Code Online (Sandbox Code Playgroud)
主要扶手:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Form validation</title>
<meta charset="utf-8">
<link rel="stylesheet" href="/public/css/style.css">
</head>
<body>
{{{body}}}
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
localhost/:12 GET http://localhost:3000/images/normal.gif 404 (Not Found)
Run Code Online (Sandbox Code Playgroud)
如果我使用完整路径,我会得到:
Not allowed to load local resource:
Run Code Online (Sandbox Code Playgroud)
我不知道为什么这不起作用。我尝试过/images/normal.gif。还尝试添加属于人员文件夹一部分的其他图像,但它只显示损坏的图像。
单击向上/向下箭头以滑动隐藏的div时,将调用此函数.如果div被隐藏,箭头指向下方并在显示div时更改为up.如果显示div,则箭头指向隐藏div并在div关闭时更改为down.我只是想知道是否有更有效的方法来做到这一点,或者这是否正确.谢谢.
function showInfo(info_id) {
var img_id = '#arrow_'+info_id;
var div = '#info_'+appointment_id;
$(div).slideToggle('normal',function() {
if ($(this).is(':visible')) {
$(img_id).attr('src',$(img_id).attr('src').replace('_down','_up'));
}
else {
$(img_id).attr('src',$(img_id).attr('src').replace('_up','_down'));
}
});}
Run Code Online (Sandbox Code Playgroud) 我有一个javascript函数来验证表单.
<script type="text/javascript">
function formValidate()
{
// create array containing textbox elements
var inputs = [document.getElementById('fname'), document.getElementById('lname'), document.getElementById('email1'), document.getElementById('email2'), document.getElementById('message')];
var error;
for(var i = 0; i<inputs.length; i++)
// loop through each element to see if value is empty
{
if(inputs[i].value == '')
{
error = 'Please complete all fields.';
alert(error);
return false;
}
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
它在html页面的头部工作,但不是我从另一个文件引用它时.
<script src="form.js" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)
表格代码:
<form onsubmit="return formValidate()" action="mailto:admin@sfasc.com.au" method="post" id="contactForm" >
Run Code Online (Sandbox Code Playgroud)
你能告诉我我做错了什么吗?