小编ian*_*ian的帖子

将javascript变量插入.innerHTML =的html输出中

我试图将传递给我的函数的变量插入到.innerHTML =代码的输出中,但不知道如何正确地将其插入到HTML输出中.

function playsong(song)
{
    parent.document.getElementById('player').innerHTML = '<object width="199" height="26"><param name="movie" value="audio_player_black.swf"><embed src="audio_player_black.swf?audio_file=upload/'[song]'&color=00000" width="199" height="26"></embed></object>';
}
Run Code Online (Sandbox Code Playgroud)

我只是在我的HTML输出中得到[song]而不是[song]的值

不知道我需要如何正确地做到这一点

html javascript

5
推荐指数
2
解决办法
3万
查看次数

在iframe中运行的javascript会影响主页吗?

部分代码:

我的下面的代码从我的数据库中提取查询,然后使用inner.HTML =来显示div中的数据.它在原始使用中工作正常....

但是,以下版本在iFrame中调用,因为它用于更新页面.

页面没有错误,然后JavaScript触发,但最后一行不起作用...

我刚刚意识到,可能因为它是在隐藏的iFrame中加载它试图在iFrame中设置div的innerHTML,当然这不会起作用.

这是发生了什么?它没有意义,因为我有另一个脚本以相同的方式在它的末尾调用JavaScript,它工作正常.

<?php
    while ($row = mysql_fetch_array($result))
    {
        $p = $p.'<div id="left"><img src="http://www.sharingizcaring.com/bleepV2/images/thumbs/'.$row[image].'" /></div>';
        $p = $p.'<div id="right"><h2>'.$row[artist].' - '.$row['title'].'</h2><br>'.$row['message'].'<br>';
        $p = $p.'<a href="http://www.sharingizcaring.com/bleepV2/'.$row[username].'">'.$row[username].'</a> '.$row[date].'</div>';
        $p = $p.'<div style="clear: both;"></div>';
        $p = $p.'<div id="dotted-line"></div>';
    }


    $p = addslashes($p);
?>

<script>

        alert('posts are firing? ');

        document.getElementById('posts').innerHTML = 'why doth this faileth?';
</script>
Run Code Online (Sandbox Code Playgroud)

javascript iframe

5
推荐指数
1
解决办法
7240
查看次数

检查较低的数字和符号的密码

我使用下面的脚本检查我的密码长度,大写,小写和数字.

如何更改它以使其检查FOR符号而不是符号?

<?php

    $password = 'afsd323A';
    if( 
        //I want to change this first line so that I am also checking for at least 1 symbol.
            ctype_alnum($password) // numbers & digits only 
        && strlen($password)>6 // at least 7 chars 
        && strlen($password)<21 // at most 20 chars 
        && preg_match('`[A-Z]`',$password) // at least one upper case 
        && preg_match('`[a-z]`',$password) // at least one lower case 
        && preg_match('`[0-9]`',$password) // at least one digit 
        )
    { 
        echo 'valid';

    }
    else
    { 
        echo 'not valid';// not valid …
Run Code Online (Sandbox Code Playgroud)

php regex

5
推荐指数
2
解决办法
2万
查看次数

在执行自定义命令时出现yii错误

当我yiic在终端中运行自定义命令时,我收到以下错误.

我似乎无法追查这个错误的原因,任何人都可以指出我正确的方向.我知道数据库工作得很好,因为应用程序的其他部分工作正常.

<?php

    class RbacCommand extends CConsoleCommand
    {
        private $_authManager;

        public function getHelp()
        {
            return "<<<EOD

            USAGE
                rbac

            DESCRIPTION
                This command generates an initial RBAC authorization hierarchy.

            EOD";
        }

        public function run($args)
        {
            if(($this->_authManager=Yii::app()->authManager)===null)
            {
                echo "Error: an authorization manager, named 'authManager' must be configured to use this command.\n";
                echo "If you already added 'authManager' component in applicaton configuration,\n";
                echo "please quit and re-enter the yiic shell.\n";
                return;
            }

            echo "This command will create three roles: Owner, Member, …
Run Code Online (Sandbox Code Playgroud)

php yii

5
推荐指数
1
解决办法
5802
查看次数

如何修复PHP中的最大执行时错误?

我有一个PHP页面,我每分钟都通过CRON作业运行.

我已经运行了很长一段时间但突然间它开始抛出这些错误:

Maximum execution time of 30 seconds exceeded in /home2/sharingi/public_html/scrape/functions.php on line 84
Run Code Online (Sandbox Code Playgroud)

行号将随每个错误而变化,范围从第70行到90年代.

这是第0-95行的代码

function crawl_page( $base_url, $target_url, $userAgent, $links)
{
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
    curl_setopt($ch, CURLOPT_URL,$target_url);
    curl_setopt($ch, CURLOPT_FAILONERROR, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 100);
    curl_setopt($ch, CURLOPT_MAXREDIRS, 10); //follow up to 10 redirections - avoids loops

    $html = curl_exec($ch);

    if (!$html) 
    {
        echo "<br />cURL error number:" .curl_errno($ch);
        echo "<br />cURL error:" . curl_error($ch);
        //exit;
    }

    //
    // load scrapped …
Run Code Online (Sandbox Code Playgroud)

php execution-time

4
推荐指数
1
解决办法
3871
查看次数

如何在我的图像和边框之间放置一个空格?

我想在我的图像和边框之间留一个空格.

做这个的最好方式是什么?

html css

4
推荐指数
2
解决办法
2万
查看次数

我可以在PHP中使用像twitter或myspace这样的直接URL

我可以做Twitter和许多其他网站在网址显示用户页面的地方.

www.mysite.com/the_user_name

在PHP ...或者如何做到这一点?

html php url

3
推荐指数
1
解决办法
241
查看次数

转换为&amp; 用于PHP中的XML

我正在为我的页面构建XML RSS.遇到这个错误:

error on line 39 at column 46: xmlParseEntityRef: no name
Run Code Online (Sandbox Code Playgroud)

显然这是因为我不能用XML格式...我在上一个字段行中做了...

什么是清理我所有$row['field']'sPHP 的最佳方法,以便转变为&amp;

php xml

3
推荐指数
1
解决办法
1万
查看次数

如何在JavaScript中正确地逃避JavaScript?

这可能是我做不到的事情......

parent.document.getElementById('<?php echo $_GET['song']; ?>')
  .innerHTML = '<img src="heart.png" onmouseover="heartOver('');" >';
Run Code Online (Sandbox Code Playgroud)

onmouseover="heartOver('');部分打破了我的JavaScript.有没有办法逃避报价,所以我可以这样做?

javascript quotes escaping

2
推荐指数
1
解决办法
1113
查看次数

我可以使用JavaScript/jQuery捕获当前/所有选项卡URL,还是需要创建插件?

我希望能够捕获所有打开的选项卡的当前URL和/或URL.

我可以在JavaScript或jQuery中执行此操作,还是需要FireFox/Chrome中的插件?

javascript url firefox jquery google-chrome

2
推荐指数
1
解决办法
2328
查看次数

标签 统计

php ×5

javascript ×4

html ×3

url ×2

css ×1

escaping ×1

execution-time ×1

firefox ×1

google-chrome ×1

iframe ×1

jquery ×1

quotes ×1

regex ×1

xml ×1

yii ×1