Javascript document.write不适用于此块
我有这个街区:Javascript document.write不适用于此块,javascript,document,Javascript,Document,我有这个街区: document.write('<div class="sz1of4 unit sm-quad"> <ul> <li><a href="/shop_pos/pos_hardware/pos_computer" alt="POS Computer">POS Computer</a></li> <li><a href="/shop_pos/pos_hard
document.write('<div class="sz1of4 unit sm-quad">
<ul>
<li><a href="/shop_pos/pos_hardware/pos_computer" alt="POS Computer">POS Computer</a></li>
<li><a href="/shop_pos/pos_hardware/touch_monitor" alt="Touch Monitor">Touch Monitor</a></li>
<li><a href="/shop_pos/pos_hardware/receipt_printer" alt="POS Receipt Printer">POS Receipt Printer</a></li>
<li><a href="/shop_pos/pos_hardware/cash_drawers" alt="Cash Drawer">Cash Drawer</a></li>
<li><a href="/shop_pos/pos_hardware/pole_display" alt="Pole Display">Pole Display</a></li>
<li><a href="/shop_pos/pos_hardware/pos_accessories/88003_002" alt="Fingerprint Scanner">Fingerprint Scanner</a></li>
<li><a href="/shop_pos/pos_hardware/pos_computer/fz43_mc2_ald" alt="Mobile POS">Mobile POS</a></li>
<li><a href="/shop_pos/pos_hardware/network/mbr900" alt="3G Backup">3G Backup</a></li>
</ul>
</div>
<div class="sz1of4 unit sm-quad">
<ul>
<li><a href="/restaurant_pos_software" alt="Restaurant POS Software">Restaurant POS Software</a></li>
<li><a href="/software/aldelo/easy.html" alt="Easy To Use">Easy To Use</a></li>
<li><a href="/software/aldelo/bar_tabs.html" alt="Bar Tabs">Bar Tabs</a></li>
<li><a href="/software/aldelo/multilingual.html" alt="Multilingual Capable">Multilingual Capable</a></li>
<li><a href="/shop_pos/point-of-sale-software/413614" alt="Quickbooks Integration">Quickbooks Integration</a></li>
<li><a href="/shop_pos/point-of-sale-software/liquor_monitor" alt="Liquor Monitor Capable">Liquor Monitor Capable</a></li>
<li><a href="/software/aldelo/reservations.html" alt="Reservations">Reservations</a></li>
<li><a href="/software/aldelo/training_mode.html" alt="Training Mode">Training Mode</a></li>
</ul>
</div>
<div class="sz1of4 unit sm-quad">
<ul>
<li><a href="/mercury/" alt="Integrated Payments">Integrated Payments</a></li>
<li><a href="http://www.mercurypay.com/products.htm" alt="Fast Transactions">Fast Transactions</a></li>
<li><a href="http://www.mercurypay.com/merchant-reports.htm" alt="Reduced Errors">Reduced Errors</a></li>
<li><a href="http://www.mercurypay.com/products.htm" alt="Secure Transactions">Secure Transactions</a></li>
<li><a href="http://www.mercurypay.com/gift-cards.htm" alt="Fee Free Gift Cards">Fee Free Gift Cards</a></li>
<li><a href="/mercury/" alt="Free 24/7 Support">Free 24/7 Support</a></li>
<li><a href="http://www.mercurypay.com/merchants.htm" alt="Competetive Pricing">Competetive Pricing</a></li>
<li><a href="/mercury/" alt="Get a Free Quote">Get a Free Quote</a></li>
</ul>
</div>
<div class="sz1of4 unit sm-quad lastUnit">
<ul>
<li><a href="http://posnation.com" alt="Free Expert Consultations">Free Expert Consultations</a></li>
<li><a href="/pos_systems/" alt="Plug & Play POS System">Plug & Play POS System</a></li>
<li><a href="/pos_support_page" alt="24/7 Support">24/7 Support</a></li>
<li><a href="/pos_live_time" alt="Live Training">Live Training</a></li>
<li><a href="/training_dvds" alt="DVD Training">DVD Training</a></li>
<li><a href="/pos_urgent" alt="Urgent Care Warranty">Urgent Care Warranty</a></li>
<li><a href="/shop_pos/pos_services" alt="Onsite Installation">Onsite Installation</a></li>
<li><a href="/shop_pos/" alt="Local Touch - Online Prices">Local Touch - Online Prices</a></li>
</ul>
</div>');
…效果很好。有什么区别?为什么大块不起作用?多行字符串必须以
\
结束每行
这里更新了小提琴:多行字符串必须以
\
结束每行
这是最新的提琴:,因为如果这些行不以
'+[newline]'结尾,js需要一行函数。
试试这个
document.write('<div class="sz1of4 unit sm-quad">'+
'<ul>'+
' <li><a href="/shop_pos/pos_hardware/pos_computer" alt="POS Computer">POS Computer</a></li>'+
' <li><a href="/shop_pos/pos_hardware/touch_monitor" alt="Touch Monitor">Touch Monitor</a></li>'+
'<li><a href="/shop_pos/pos_hardware/receipt_printer" alt="POS Receipt Printer">POS Receipt Printer</a></li>'+
'<li><a href="/shop_pos/pos_hardware/cash_drawers" alt="Cash Drawer">Cash Drawer</a></li>'+
'<li><a href="/shop_pos/pos_hardware/pole_display" alt="Pole Display">Pole Display</a></li>'+
' <li><a href="/shop_pos/pos_hardware/pos_accessories/88003_002" alt="Fingerprint Scanner">Fingerprint Scanner</a></li>'+
' <li><a href="/shop_pos/pos_hardware/pos_computer/fz43_mc2_ald" alt="Mobile POS">Mobile POS</a></li>'+
' <li><a href="/shop_pos/pos_hardware/network/mbr900" alt="3G Backup">3G Backup</a></li>'+
'</ul>'+
'</div>'+
'<div class="sz1of4 unit sm-quad">'+
' <ul>'+
' <li><a href="/restaurant_pos_software" alt="Restaurant POS Software">Restaurant POS Software</a></li>'+
' <li><a href="/software/aldelo/easy.html" alt="Easy To Use">Easy To Use</a></li>'+
' <li><a href="/software/aldelo/bar_tabs.html" alt="Bar Tabs">Bar Tabs</a></li>'+
' <li><a href="/software/aldelo/multilingual.html" alt="Multilingual Capable">Multilingual Capable</a></li>'+
' <li><a href="/shop_pos/point-of-sale-software/413614" alt="Quickbooks Integration">Quickbooks Integration</a></li>'+
' <li><a href="/shop_pos/point-of-sale-software/liquor_monitor" alt="Liquor Monitor Capable">Liquor Monitor Capable</a></li>'+
' <li><a href="/software/aldelo/reservations.html" alt="Reservations">Reservations</a></li>'+
' <li><a href="/software/aldelo/training_mode.html" alt="Training Mode">Training Mode</a></li>'+
' </ul>'+
'</div>'+
'<div class="sz1of4 unit sm-quad">'+
' <ul>'+
' <li><a href="/mercury/" alt="Integrated Payments">Integrated Payments</a></li>'+
' <li><a href="http://www.mercurypay.com/products.htm" alt="Fast Transactions">Fast Transactions</a></li>'+
' <li><a href="http://www.mercurypay.com/merchant-reports.htm" alt="Reduced Errors">Reduced Errors</a></li>'+
' <li><a href="http://www.mercurypay.com/products.htm" alt="Secure Transactions">Secure Transactions</a></li>'+
' <li><a href="http://www.mercurypay.com/gift-cards.htm" alt="Fee Free Gift Cards">Fee Free Gift Cards</a></li>'+
' <li><a href="/mercury/" alt="Free 24/7 Support">Free 24/7 Support</a></li>'+
' <li><a href="http://www.mercurypay.com/merchants.htm" alt="Competetive Pricing">Competetive Pricing</a></li>'+
' <li><a href="/mercury/" alt="Get a Free Quote">Get a Free Quote</a></li>'+
'</ul>'+
'</div>'+
'<div class="sz1of4 unit sm-quad lastUnit">'+
' <ul>'+
' <li><a href="http://posnation.com" alt="Free Expert Consultations">Free Expert Consultations</a></li>'+
' <li><a href="/pos_systems/" alt="Plug & Play POS System">Plug & Play POS System</a></li>'+
' <li><a href="/pos_support_page" alt="24/7 Support">24/7 Support</a></li>'+
' <li><a href="/pos_live_time" alt="Live Training">Live Training</a></li>'+
'<li><a href="/training_dvds" alt="DVD Training">DVD Training</a></li>'+
' <li><a href="/pos_urgent" alt="Urgent Care Warranty">Urgent Care Warranty</a></li>'+
' <li><a href="/shop_pos/pos_services" alt="Onsite Installation">Onsite Installation</a></li>'+
' <li><a href="/shop_pos/" alt="Local Touch - Online Prices">Local Touch - Online Prices</a></li>'+
'</ul>'+
'</div>');
document.write(“”+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“
”+
''+
''+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“
”+
''+
''+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“
”+
''+
''+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“
”+
'');
,因为如果这些行不以'+[newline]'结尾,js需要单行函数。
试试这个
document.write('<div class="sz1of4 unit sm-quad">'+
'<ul>'+
' <li><a href="/shop_pos/pos_hardware/pos_computer" alt="POS Computer">POS Computer</a></li>'+
' <li><a href="/shop_pos/pos_hardware/touch_monitor" alt="Touch Monitor">Touch Monitor</a></li>'+
'<li><a href="/shop_pos/pos_hardware/receipt_printer" alt="POS Receipt Printer">POS Receipt Printer</a></li>'+
'<li><a href="/shop_pos/pos_hardware/cash_drawers" alt="Cash Drawer">Cash Drawer</a></li>'+
'<li><a href="/shop_pos/pos_hardware/pole_display" alt="Pole Display">Pole Display</a></li>'+
' <li><a href="/shop_pos/pos_hardware/pos_accessories/88003_002" alt="Fingerprint Scanner">Fingerprint Scanner</a></li>'+
' <li><a href="/shop_pos/pos_hardware/pos_computer/fz43_mc2_ald" alt="Mobile POS">Mobile POS</a></li>'+
' <li><a href="/shop_pos/pos_hardware/network/mbr900" alt="3G Backup">3G Backup</a></li>'+
'</ul>'+
'</div>'+
'<div class="sz1of4 unit sm-quad">'+
' <ul>'+
' <li><a href="/restaurant_pos_software" alt="Restaurant POS Software">Restaurant POS Software</a></li>'+
' <li><a href="/software/aldelo/easy.html" alt="Easy To Use">Easy To Use</a></li>'+
' <li><a href="/software/aldelo/bar_tabs.html" alt="Bar Tabs">Bar Tabs</a></li>'+
' <li><a href="/software/aldelo/multilingual.html" alt="Multilingual Capable">Multilingual Capable</a></li>'+
' <li><a href="/shop_pos/point-of-sale-software/413614" alt="Quickbooks Integration">Quickbooks Integration</a></li>'+
' <li><a href="/shop_pos/point-of-sale-software/liquor_monitor" alt="Liquor Monitor Capable">Liquor Monitor Capable</a></li>'+
' <li><a href="/software/aldelo/reservations.html" alt="Reservations">Reservations</a></li>'+
' <li><a href="/software/aldelo/training_mode.html" alt="Training Mode">Training Mode</a></li>'+
' </ul>'+
'</div>'+
'<div class="sz1of4 unit sm-quad">'+
' <ul>'+
' <li><a href="/mercury/" alt="Integrated Payments">Integrated Payments</a></li>'+
' <li><a href="http://www.mercurypay.com/products.htm" alt="Fast Transactions">Fast Transactions</a></li>'+
' <li><a href="http://www.mercurypay.com/merchant-reports.htm" alt="Reduced Errors">Reduced Errors</a></li>'+
' <li><a href="http://www.mercurypay.com/products.htm" alt="Secure Transactions">Secure Transactions</a></li>'+
' <li><a href="http://www.mercurypay.com/gift-cards.htm" alt="Fee Free Gift Cards">Fee Free Gift Cards</a></li>'+
' <li><a href="/mercury/" alt="Free 24/7 Support">Free 24/7 Support</a></li>'+
' <li><a href="http://www.mercurypay.com/merchants.htm" alt="Competetive Pricing">Competetive Pricing</a></li>'+
' <li><a href="/mercury/" alt="Get a Free Quote">Get a Free Quote</a></li>'+
'</ul>'+
'</div>'+
'<div class="sz1of4 unit sm-quad lastUnit">'+
' <ul>'+
' <li><a href="http://posnation.com" alt="Free Expert Consultations">Free Expert Consultations</a></li>'+
' <li><a href="/pos_systems/" alt="Plug & Play POS System">Plug & Play POS System</a></li>'+
' <li><a href="/pos_support_page" alt="24/7 Support">24/7 Support</a></li>'+
' <li><a href="/pos_live_time" alt="Live Training">Live Training</a></li>'+
'<li><a href="/training_dvds" alt="DVD Training">DVD Training</a></li>'+
' <li><a href="/pos_urgent" alt="Urgent Care Warranty">Urgent Care Warranty</a></li>'+
' <li><a href="/shop_pos/pos_services" alt="Onsite Installation">Onsite Installation</a></li>'+
' <li><a href="/shop_pos/" alt="Local Touch - Online Prices">Local Touch - Online Prices</a></li>'+
'</ul>'+
'</div>');
document.write(“”+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“
”+
''+
''+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“
”+
''+
''+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“
”+
''+
''+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“”+
“
”+
'');
<代码> > p>第一个在字符串中间有一个(字面)新行。在JS中不能这样做。 < P>第一个在字符串中间有一个(字面)新行。在JS中不能这样做。JavaScript不支持,这就是为什么这个示例不适合您
您最好使用类似这样的东西来达到您想要达到的目的。JavaScript不支持,这就是为什么该示例不适用于您
您最好使用类似这样的工具来达到您想要达到的目的。请在您的问题中发布代码片段。链接到JSFIDLE是一个很好的方法。请在您的问题中发布代码片段。链接到JSFIDLE是一个很好的方法。