2013-01-11 19 views
-3

我需要JavaScript的標籤,這不需要<head>版(它不會是posible)。用於製作標籤的JavaScript不需要<head>版本?

我有三個鏈接和三個div,我需要這樣的東西,鏈接推會顯示一個div,其他隱藏,其他鏈接推,顯示其他div和所有其他隱藏然後。

這裏是我的代碼:

<div style="text-align: left;"> 
      <ul style="margin: 0 0 0 0;"> 
       <li style="display:inline; margin-left: 3px; text-align: center; width:90px; background-color:#58794c; border-top:1px dotted #015811; border-left:1px dotted #015811; border-right:1px dotted #015811;"><a style="color: #ffffff; font-size: 28px; text-decoration: none;" href="#">Postage</a></li> 
       <li style="display:inline; margin-left: 3px; text-align: center; width:90px; background-color:#558b40; border-top:1px dotted #015811; border-left:1px dotted #015811; border-right:1px dotted #015811;"><a style="color: #efda5d; font-size: 28px; text-decoration: none;" href="#">Return</a></li> 
       <li style="display:inline; margin-left: 3px; text-align: center; width:90px; background-color:#66ac4a; border-top:1px dotted #015811; border-left:1px dotted #015811; border-right:1px dotted #015811;"><a style="color: #efda5d; font-size: 28px; text-decoration: none;" href="#">Payment</a></li> 
      </ul> 
     </div> 
     <div style="width:324px; background-color:#58794c; color: #efda5d; border-bottom:1px dotted #015811; border-left:1px dotted #015811; border-right:1px dotted #015811;" title="Shipping information"><p style="text-align: left; margin-left: 10; margin-top:0;">Available shipping type/It's price/Additional cost for this product:<br />[[ShippingService1]]/[[ShippingServiceCost1]]/[[ShippingServiceAdditionalCost1]]<br />[[ShippingService2]]/[[ShippingServiceCost2]]/[[ShippingServiceAdditionalCost2]]<br />[[ShippingService3]]/[[ShippingServiceCost3]]/[[ShippingServiceAdditionalCost3]]<br />More information about products delivery you will find by clicking <a style="color: #ffffff;" href="http://stores.ebay.co.uk/Digi-Spot/Delivery.html">here</a>.</p></div> 
     <div style="width:324px; background-color:#558b40; color: #efda5d; border-bottom:1px dotted #015811; border-left:1px dotted #015811; border-right:1px dotted #015811;" title="Return information"><p style="text-align: left; margin-left: 10; margin-top:0;">Product must be returned within [[ReturnWithin]] to this adress <b>[[ReturnAddress]]</b>. For return shipping pays <b>[[ReturnShipPaid]]</b>.<br /> More information about returning products you will find by clicking <a style="color: #ffffff;" href="http://stores.ebay.co.uk/Digi-Spot/Returns.html">here</a>.</p></div> 
     <div style="width:324px; background-color:#66ac4a; color: #efda5d; border-bottom:1px dotted #015811; border-left:1px dotted #015811; border-right:1px dotted #015811;" title="Payment information"><p style="text-align: left; margin-left: 10; margin-top:0;">Product price is <b>[[FixedPrice]]</b><br />Additional payment instructions for this product: [[PaymentInstructions]]</p></div> 

而這就是我想要的一個例子:http://www.isdntek.com/tagbot/tabtop.htm

也許我需要添加的div名稱或ID,並有顯示或隱藏的簡單函數divs(這將執行鏈接點擊),但我找不到一個不需要編輯<head>

+1

歡迎來到Stack Overflow。請注意,發佈系統接受某些HTML標籤,因此當您需要顯示文字標籤時,您必須使用工具欄按鈕將其標記爲代碼。這次我爲你做了。 –

+2

「我需要JavaScript的標籤,不需要''版(它不會是posible)。」 - 這是任何標籤庫(即使情況並非如此,如果您無法修改頭部,則需要修復CMS或修復不允許修改的業務文化) – Quentin

+0

eBay不允許在列表模板中進行修改。無論如何感謝您的建議 – Tautvydas

回答

0

正如Quentin所說,在對您的問題發表評論時,幾乎任何提供標籤小部件(或任何其他解決方案來構建標籤)的JavaScript庫都不需要在頁面的<head>部分執行任何操作。嗯......其實這樣做,因爲你把調用到外部JavaScript文件有:

<script type="text/javascript" src="libs.js"></script> 

但是,這只是一個讓你的代碼乾淨的形式。如果你不太喜歡頭部,你可以在你的<body></body>部分幾乎任何地方放置同一條線,它也應該可以工作。

因此,如果可能每個提供製表符的JavaScript庫都可以在沒有修改<head>的情況下工作,那麼讓我們使用世界上最多(或幾乎最多)着名的 - jQuery UI

正如你可以在給定的例子中看到的(點擊「查看源代碼」),所有你需要做的,得到的標籤,就是把你的<body></body>是這樣的:

<div id="tabs"> 
    <ul> 
     <li><a href="#tabs-1">Tab 1 Title</a></li> 
     <li><a href="#tabs-2">Tab 2 Title</a></li> 
     <li><a href="#tabs-3">Tab 3 Title</a></li> 
    </ul> 
    <div id="tabs-1"> 
     <p>Tab 1 Text</p> 
    </div> 
    <div id="tabs-2"> 
     <p>Tab 2 Text</p> 
    </div> 
    <div id="tabs-3"> 
     <p>Tab 3 Text</p> 
    </div> 
</div> 

然後再次,jQuery UI的作者會告訴你,你應該把調用的jQuery的jQuery UI的庫最新版本到您的<head></head>部分:

<script src="http://code.jquery.com/jquery-1.8.3.js"></script> 
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script> 

但是,正如我寫信給你,你也可以把這個在任何地方,例如,只是用來<div>之前聲明的標籤:

<script src="http://code.jquery.com/jquery-1.8.3.js"></script> 
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script> 
<div id="tabs"> 
    <ul> 
    ... 

這將是所有的,鄉親們! :]

相關問題