未捕获的ReferenceError:使用btn按钮分配无效的左侧

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了未捕获的ReferenceError:使用btn按钮分配无效的左侧相关的知识,希望对你有一定的参考价值。

只有在预订了优惠条目时,才会在基本条目中显示通过引导按钮的链接。这应在Worldsoft CMS的门户模块中实现。

第一个解决方案适用于Chrome,IE等,但不适用于Firefox。如果我点击按钮,那里什么也没发生。我认为,在<a>中有一个<button>是无效的。首先,我将使用给定的<wstag>显示代码,然后我将告诉您将使用它做什么:

<---First solution works good (Code with tags):------------------------->
<script type='text/javascript'>
detailbutton();
function detailbutton() {  
    var tiendadetails = ('<wstag class="wsTag" id="306" type="ddbf_137" 
widget="checkbox">Portal Field :: Tienda-Details</wstag>');
    if (tiendadetails == 'Premium-Eintrag') 
         { document.write("<button class='btn btn-warning'>" + "<wstag 
class="wsTag" id="290" type="PORTALS_MORE" widget="link">" + "Portals :: 
Mehr..." + "</wstag>" + "</button>"); } 
    else { document.write('<p style="color: #ff0000;">only basic entry, 
no further information</p>'); }
}
</script>

<---First solution (Code looks resolved like this):--------------------->
<script type='text/javascript'>
detailbutton();
function detailbutton() {  
    var tiendadetails = ('Premium-Eintrag');
    if (tiendadetails == 'Premium-Eintrag') 
        { document.write("<button class='btn btn-warning'>" + "<a 
href='/portal/9/68/tiendassantanyi/cult?     
portal_id=16&peid=9&q=&next=22,30,e&previous=s&qid=3cp8rbc8erv1klro299d02
mdn4&p=&location_id=68' >Premium Entry: Click here for important details! 
</a>" + "</button>"); } 
    else { document.write('<p style="color: #ff0000;">only basic entry, 
no further information</p>'); }
}
</script>

我的新解决方案反而得到以下错误消息:

Uncaught ReferenceError: Invalid left-hand side in assignment

(符合“var premium ...”)

<!---------------New Script Button for Premium-Eintrag------------------>
<script type='text/javascript'>
premium();
function premium() { 
    var premium = ('<wstag class="wsTag" id="290" type="PORTALS_MORE" 
widget="link">Portals :: Mehr...</wstag>'); 
}
detailbutton();
function detailbutton() {
    var tiendadetails = ('<wstag class="wsTag" id="306" type="ddbf_137" 
widget="checkbox">Portal Field :: Tienda-Details</wstag>');
    if (tiendadetails == 'Premium-Eintrag')
        { document.write('<button class="btn btn-warning" id="premium"> 
</button>'); } 
    else { document.write('<p style="color: #ff0000;">only basic entry, 
no further information</p>'); }
}
</script>

<!----------------------looks resolved like this------------------------>
<script type="text/javascript">
premium();
function premium(){ 
var premium = ('<a href='/portal/9/68/tiendassantanyi/cult? 
portal_id=16&peid=9&q=&next=22,30,e&previous=s&qid=3cp8rbc8erv1klro299d02
mdn4&p=&location_id=68' >Premium Entry: Click here for important details! 
</a>'); 
}
detailbutton();
function detailbutton(){
    var tiendadetails = ('Premium-Eintrag');
    if (tiendadetails == 'Premium-Eintrag')
        { document.write('<button class="btn btn-warning" id="premium"> 
</button>'); } 
    else { document.write('<p style="color: #ff0000;">only basic entry, 
no further information</p>'); }
}
</script>

我没有发现我的错误!?你有什么主意吗?

答案

请注意var premium中的简单或双引号

使用

var premium = ('<a href="your url" >Premium Entry: Click here for important details! </a>');

代替

var premium = ('<a href='your url' >Premium Entry: Click here for important details! </a>');

以上是关于未捕获的ReferenceError:使用btn按钮分配无效的左侧的主要内容,如果未能解决你的问题,请参考以下文章

未捕获的 ReferenceError:未使用 onclick 定义函数

使用 es6 模块:未捕获的 ReferenceError:未定义定义

未捕获的 ReferenceError:未定义 jstz

未捕获的 ReferenceError:未定义 ACDesigner

未捕获的 ReferenceError: $http 未定义

未捕获的 ReferenceError:未定义主干