任何人都可以知道我如何从我的网站 truebatteries.com 中删除额外的 javascript 代码
那么,从 SEO 的角度来看,我如何从网站中删除 javascript 代码,这对我们来说太糟糕了..
例子
请看看我们是否可以通过 HTTP 请求将此内部 JAVASCRIPT 代码变为外部文件或将其完全删除
Here is the INTERNAL JAVASCRIPT for CURRENCY CONVERTER that can be found on the site.
<scripttype="text/javascript">
function get_url_var(url_var) {
varurlHalves = String(document.location).toLowerCase().split('?');
varurlVarValue = '';
if (urlHalves[1]) {
varurlVars = urlHalves[1].split('&');
for (var i = 0; i <= (urlVars.length); i++) {
if (urlVars[i]) {
varurlVarPair = urlVars[i].split('=');
if (urlVarPair[0] &&urlVarPair[0] == url_var.toLowerCase()) {
urlVarValue = urlVarPair[1];
}
}
}
}
return urlVarValue;
}
$(document).ready(function () {
$('#bussoc-paypal-express').live('click', function() {
$.ajax({
url: 'https://www.genuinebatteries.com/payment/bussoc_paypal_express/init',
type: 'get',
dataType: 'json',
success: function(json) {
$('.success, .warning, .attention, information, .error').remove();
if (json['error']) {
if (json['error']) {
$('#notification').html('<div class="warning" style="display: none;">' + json['error'] + '<imgsrc="catalog/view/theme/default/image/close.png" alt="" class="close" /></div>');
$('.warning').fadeIn('slow');
}
}
if (json['redirect']) {
location = json['redirect'];
}
}
});
});
if (get_url_var('route') == 'checkout/cart') {
varobj = $('#content h1');
if (obj != undefined ) {
$(obj).append('<div style="float:right; margin-top:6px;"><a id="bussoc-paypal-express" ><imgsrc="catalog/view/theme/default/image/btn_xpressCheckout.gif" alt="Paypal Express" /></a></div>');
}
}
});
感谢您的回复,我按照您的指示做了,但它不起作用,以下是我需要从货币转换器模块的内部文件移入外部文件的代码,请参阅 tpl 文件的代码
javascript代码在最后,然后我将它移动到另一个文件并像这样引用它,请参阅....
<div class="box">
<div class="box-currency">
<div class="c-amount">
<?php echo $text_amount; ?>
<input style="text-align:right" type="text" size="10" value="<?php echo $currency_value; ?>" name="currency_value"/>
</div>
<div class="c-from">
<?php echo $text_from; ?><br />
<select style="max-width:160px" name="currency_from">
<?php foreach($currencies as $currency){ ?>
<option <?php echo ($currency['currency_code'] == $currency_from) ? 'selected="selected"' : ''; ?> value="<?php echo $currency['currency_code']; ?>"><?php echo $currency['currency_name'].'('.$currency['country_code'].')';?></option>
<?php } ?>
</select>
</div>
<div class="c-to">
<?php echo $text_to;?><br />
<select style="max-width:160px" name="currency_to">
<?php foreach($currencies as $currency){ ?>
<option <?php echo ($currency['currency_code'] == $currency_to) ? 'selected="selected"' : ''; ?> value="<?php echo $currency['currency_code']; ?>"><?php echo $currency['currency_name'].'('.$currency['country_code'].')';?></option>
<?php } ?>
</select>
</div><br />
<div style="text-align:center" class="converter">
<div id="c-loadding"></div>
<a class="button" id="goconverter" ><span><?php echo $text_converter;?></span></a>
</div><br />
<div class="c-results">
<p class="prices"> <?php echo $currency_value.$currency_from.' = '.$currencyconverter['amount'].$currency_to; ?></p>
<p style="font-size:10px"><?php echo $text_rate.$currencyconverter['date'].' '.$currencyconverter['time']; ?></p>
</div>
</div>
Javascript代码如下,我从底部的上方文件中获取
<script type="text/javascript"><!--
$('a#goconverter').bind('click',function(){
$.ajax({
type: 'POST',
url: 'index.php?route=module/currencyconverter',
data: 'currency_value=' + encodeURIComponent($('input[name=\'currency_value\']').val()) + '¤cy_from=' + encodeURIComponent($('select[name=\'currency_from\']').val()) + '¤cy_to=' + encodeURIComponent($('select[name=\'currency_to\']').val()),
dataType: 'json',
beforeSend: function() {
$('#c-loadding').html('<img src="catalog/view/theme/default/image/loading.gif" id="loading" style="padding-left: 5px;" />');
},
success:function(json){
if(json.error)
{
$('.c-results').html('<p style="color:red">'+json.error+'</p>');
$('#c-loadding').html('');
}
if(json.currencyconverter)
{
var html = '';
html += '<p class="prices">';
html += json.currency_value + json.currency_from;
html += ' = '+ json.currencyconverter['amount'] +'';
html += json.currency_to;
html += '</p>';
html += '<p style="font-size:10px">';
html += '<?php echo $text_rate; ?>';
html += json.currencyconverter['date']+json.currencyconverter['time'];
html += '</p>';
$('.c-results').html(html);
$('#c-loadding').html('');
}
}
})
});
//-->