Javascript 解析dom元素时JqueryUI滑块不工作
我使用的是简单的HTMLDOM解析器。 我的代码一切正常,但jqueryui不工作,对于某些站点,它不显示图像。 请检查现场 请尝试使用简单的HTML 请在带有URL的文本字段中输入URL。 您可以看到图像未加载,滑块未工作。 这是我的密码Javascript 解析dom元素时JqueryUI滑块不工作,javascript,php,jquery,html,jquery-ui,Javascript,Php,Jquery,Html,Jquery Ui,我使用的是简单的HTMLDOM解析器。 我的代码一切正常,但jqueryui不工作,对于某些站点,它不显示图像。 请检查现场 请尝试使用简单的HTML 请在带有URL的文本字段中输入URL。 您可以看到图像未加载,滑块未工作。 这是我的密码 <?php include_once 'simple_html_dom.php'; $data = new simple_html_dom(); if ( isset($_REQUEST['url_name']) ) { if ( strpo
<?php
include_once 'simple_html_dom.php';
$data = new simple_html_dom();
if ( isset($_REQUEST['url_name']) ) {
if ( strpos($_REQUEST['url_name'], "http://") === false && strpos($_REQUEST['url_name'], "//") === false ) {
$_REQUEST['url_name']="http://".$_REQUEST['url_name'];
}
$url_name = $_REQUEST['url_name'];
if ( strpos($_REQUEST['url_name'], "/") === false ) {
$url_name = $_REQUEST['url_name'].'/';
}
// Load HTML from an URL
$data->load_file($_REQUEST['url_name']);
foreach ( $data->find('img') as $element ) {
$element->target='_blank';
if ( strpos($element, ".com") === false
&& strpos($element, ".net") === false
&& strpos($element, ".org") === false
&& strpos($element, "http://") === false
&& strpos($element, "https://") === false
){
$element->src=$url_name.$element->src;
}
}
foreach ( $data->find('style') as $element ) {
if ( strpos($element, ".com") === false
&& strpos($element, ".net") === false
&& strpos($element, ".org") === false
&& strpos($element, "http://") === false
&& strpos($element, "https://") === false
){
$element->src=$url_name.$element->src;
}
}
foreach ( $data->find('script') as $element ) {
if ( strpos($element, ".com") === false
&& strpos($element, ".net") === false
&& strpos($element, ".org") === false
&& strpos($element, "http://") === false
&& strpos($element, "https://") === false
){
$element->src=$url_name.$element->src;
}
}
foreach ( $data->find('link') as $element ) {
if ( strpos($element, ".com") === false
&& strpos($element, ".net") === false
&& strpos($element, ".org") === false
&& strpos($element, "http://") === false
&& strpos($element, "https://") === false
){
$element->href=$url_name.$element->href;
}
}
foreach ( $data->find('a') as $element ) {
if ( strpos($element->href, ".com") === false
&& strpos($element->href, ".net") === false
&& strpos($element->href, ".org") === false
&& strpos($element->href, "http://") === false
&& strpos($element->href, "https://") === false
){
$element->href = "form_submit.php?url_name=".$url_name.$element->href;
} else {
$element->href = "form_submit.php?url_name=".$element->href;
}
}
echo $newHtml;
}
?>
您想做什么?
我猜您需要一个所有托管img、css、js和URL的列表。
$newHtml
从未在代码中的任何位置定义过simple\u html\u dom
类是什么?我假设是这样的:
- 或者,或者您打算
回显$data代码>在末尾
simple\u html\u dom
实际上是什么,我所能做的就是向你介绍一些更高级的东西
编码概念
- 在代码样式中正确使用空格
- 有些人会不同意我在这里的选择,但这大大提高了可读性
- 如果你有很长的队伍,把他们分开
- 如果在整个代码中重复着几乎相同的代码块,那么它可能是一个函数
- 调试/故障排除时,要么回显所有内容,要么使用调试器(xdebug)
- 更好地评论你的代码,我没有在这里教你为什么你总是应该
请发布您的代码。@Gjohn抱歉,测试url是@Gjohn所有图像大小都设置为0px,用于测试url。@virendra您知道如何解决吗?请帮帮我。你到底想用这段代码实现什么?这是难以置信的难读。小提示:如果您发现自己用单行注释描述代码的某些部分,那么应该删除注释,并将该块移动到单独的函数中。