我想在页面完全加载时调用URL
。所以我想出了这个
$(window).load(function() {
url: "https://shareasale.com/sale.cfm?amount=90.00&tracking=30&transtype=sale&merchantID=xxxxx"
});
网址最初是这样的:
<img src="https://shareasale.com/sale.cfm?amount=99.00&tracking=15&transtype=sale&merchantID=xxxxx" width="1" height="1">
我不知道如何在javascript / jquery中调用img
标记。所以我尝试在url
函数中使用load()
。我真的需要帮助。
答案 0 :(得分:1)
试试这个: 从图片标记中获取网址
'urlManager' => [
'class' => 'yii\web\UrlManager',
// Disable index.php
'showScriptName' => false,
// Disable r= routes
'enablePrettyUrl' => true,
'rules' => array(
'<controller:\w+>/<id:\d+>' => 'news/view',
'<controller:\w+>/<link>' => 'news/latestnews', // This is required for $link parameter
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>/<link>' => 'news/latestnews',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
],
],
&#13;
$(window).load(function() {
var url= $('img').attr('src')
console.log(url)
});
&#13;
将网址加载到图片
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<img src="https://shareasale.com/sale.cfm?amount=99.00&tracking=15&transtype=sale&merchantID=xxxxx" width="1" height="1">
&#13;
$(window).load(function() {
var url="https://shareasale.com/sale.cfm?amount=99.00&tracking=15&transtype=sale&merchantID=xxxxx";
var url= $('img').attr('src',url)
console.log($('img').attr('src'))
});
&#13;