我仅在移动网站上收到脚本错误。在桌面网站上没有错误,它可以正确呈现。
错误是:
Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script
除非明确打开。
的javascript
function localCurrencyChange(lcfrom, lcvalues, postid) {
var lcselectname = document.getElementById("lc_currency" + postid);
var lctoindex = lcselectname.selectedIndex;
var lcto = lcselectname.options[lctoindex].value;
localCurrency(lcfrom, lcto, lcvalues, postid);
}
function localCurrencyObject(id, name, symbol) {
this.id = id;
this.name = name;
this.symbol = symbol;
}
var localcurrency_array = new Array();
localcurrency_array['0'] = new localCurrencyObject('USD', 'United States Dollar (USD)', '$');
localcurrency_array['1'] = new localCurrencyObject('GBP', 'British Pound (GBP)', '£');
localcurrency_array['2'] = new localCurrencyObject('EUR', 'Euro (EUR)', '€');
localcurrency_array['3'] = new localCurrencyObject('AUD', 'Australian Dollar (AUD)', '$');
localcurrency_array['4'] = new localCurrencyObject('CAD', 'Canadian Dollar (CAD)', '$');
localcurrency_array['5'] = new localCurrencyObject('NZD', 'New Zealand Dollar (NZD)', '$');
localcurrency_array['6'] = new localCurrencyObject('CNY', 'Chinese Yuan (CNY)', '元');
localcurrency_array['7'] = new localCurrencyObject('JPY', 'Japanese Yen (JPY)', '¥');
localcurrency_array['8'] = new localCurrencyObject('RUB', 'Russian Rouble (RUB)', 'руб');
localcurrency_array['9'] = new localCurrencyObject('---', '------------------- (---)', '---');
localcurrency_array['10'] = new localCurrencyObject('AFN', 'Afghanistan Afghani (AFN)', '؋');
localcurrency_array['11'] = new localCurrencyObject('ALL', 'Albanian Lek (ALL)', 'Lek');
localcurrency_array['12'] = new localCurrencyObject('DZD', 'Algerian Dinar (DZD)', 'د.ج');
localcurrency_array['13'] = new localCurrencyObject('ARS', 'Argentine Peso (ARS)', '$');
localcurrency_array['14'] = new localCurrencyObject('AMD', 'Armenian Dram (AMD)', '֏');
localcurrency_array['15'] = new localCurrencyObject('AWG', 'Aruba Florin (AWG)', 'ƒ');
localcurrency_array['16'] = new localCurrencyObject('AZN', 'Azerbaijan New Manat (AZN)', 'm');
localcurrency_array['17'] = new localCurrencyObject('BSD', 'Bahamian Dollar (BSD)', '$');
localcurrency_array['18'] = new localCurrencyObject('BHD', 'Bahraini Dinar (BHD)', 'ب.د');
localcurrency_array['19'] = new localCurrencyObject('BDT', 'Bangladesh Taka (BDT)', '');
localcurrency_array['20'] = new localCurrencyObject('BBD', 'Barbados Dollar (BBD)', '$');
localcurrency_array['21'] = new localCurrencyObject('BYR', 'Belarus Ruble (BYR)', 'p.');
localcurrency_array['22'] = new localCurrencyObject('BZD', 'Belize Dollar (BZD)', '$');
localcurrency_array['23'] = new localCurrencyObject('BMD', 'Bermuda Dollar (BMD)', '$');
localcurrency_array['24'] = new localCurrencyObject('BTN', 'Bhutan Ngultrum (BTN)', '');
localcurrency_array['25'] = new localCurrencyObject('BOB', 'Bolivian Boliviano (BOB)', '$b');
localcurrency_array['26'] = new localCurrencyObject('BAM', 'Bosnia and Herzegovina Convertible Marka (BAM)', 'KM');
localcurrency_array['27'] = new localCurrencyObject('BWP', 'Botswana Pula (BWP)', 'P');
localcurrency_array['28'] = new localCurrencyObject('BRL', 'Brazilian Real (BRL)', 'R$');
localcurrency_array['29'] = new localCurrencyObject('BND', 'Brunei Dollar (BND)', '$');
localcurrency_array['30'] = new localCurrencyObject('BGN', 'Bulgarian Lev (BGN)', 'лв');
localcurrency_array['31'] = new localCurrencyObject('BIF', 'Burundi Franc (BIF)', 'Fr');
localcurrency_array['32'] = new localCurrencyObject('KHR', 'Cambodia Riel (KHR)', '៛');
localcurrency_array['33'] = new localCurrencyObject('CVE', 'Cape Verde Escudo (CVE)', '');
localcurrency_array['34'] = new localCurrencyObject('KYD', 'Cayman Islands Dollar (KYD)', '$');
localcurrency_array['35'] = new localCurrencyObject('XOF', 'CFA Franc (BCEAO) (XOF)', 'Fr');
localcurrency_array['36'] = new localCurrencyObject('XAF', 'CFA Franc (BEAC) (XAF)', 'Fr');
localcurrency_array['37'] = new localCurrencyObject('CLP', 'Chilean Peso (CLP)', '$');
localcurrency_array['38'] = new localCurrencyObject('COP', 'Colombian Peso (COP)', '$');
localcurrency_array['39'] = new localCurrencyObject('KMF', 'Comoros Franc (KMF)', 'Fr');
localcurrency_array['40'] = new localCurrencyObject('CDF', 'Congolese franc (CDF)', '');
localcurrency_array['41'] = new localCurrencyObject('CRC', 'Costa Rica Colon (CRC)', '₡');
localcurrency_array['42'] = new localCurrencyObject('HRK', 'Croatian Kuna (HRK)', 'kn');
localcurrency_array['43'] = new localCurrencyObject('CUP', 'Cuban Peso (CUP)', '₱');
localcurrency_array['44'] = new localCurrencyObject('CZK', 'Czech Koruna (CZK)', 'Kč');
localcurrency_array['45'] = new localCurrencyObject('DKK', 'Danish Krone (DKK)', 'kr');
localcurrency_array['46'] = new localCurrencyObject('DJF', 'Dijibouti Franc (DJF)', 'Fr');
localcurrency_array['47'] = new localCurrencyObject('DOP', 'Dominican Peso (DOP)', 'RD$');
localcurrency_array['48'] = new localCurrencyObject('XCD', 'East Caribbean Dollar (XCD)', '$');
localcurrency_array['49'] = new localCurrencyObject('EGP', 'Egyptian Pound (EGP)', '£');
localcurrency_array['50'] = new localCurrencyObject('ERN', 'Eritrea Nakfa (ERN)', 'Nfk');
localcurrency_array['51'] = new localCurrencyObject('ETB', 'Ethiopian Birr (ETB)', '');
localcurrency_array['52'] = new localCurrencyObject('FKP', 'Falkland Islands Pound (FKP)', '£');
localcurrency_array['53'] = new localCurrencyObject('FJD', 'Fiji Dollar (FJD)', '$');
localcurrency_array['54'] = new localCurrencyObject('GMD', 'Gambian Dalasi (GMD)', 'D');
localcurrency_array['55'] = new localCurrencyObject('GEL', 'Georgian Lari (GEL)', 'ლ');
localcurrency_array['56'] = new localCurrencyObject('GHS', 'Ghanian Cedi (GHS)', '¢');
localcurrency_array['57'] = new localCurrencyObject('GIP', 'Gibraltar Pound (GIP)', '£');
localcurrency_array['58'] = new localCurrencyObject('GTQ', 'Guatemala Quetzal (GTQ)', 'Q');
localcurrency_array['59'] = new localCurrencyObject('GNF', 'Guinea Franc (GNF)', 'Fr');
localcurrency_array['60'] = new localCurrencyObject('GYD', 'Guyana Dollar (GYD)', '$');
localcurrency_array['61'] = new localCurrencyObject('HTG', 'Haiti Gourde (HTG)', '');
localcurrency_array['62'] = new localCurrencyObject('HNL', 'Honduras Lempira (HNL)', 'L');
localcurrency_array['63'] = new localCurrencyObject('HKD', 'Hong Kong Dollar (HKD)', '$');
localcurrency_array['64'] = new localCurrencyObject('HUF', 'Hungarian Forint (HUF)', 'Ft');
localcurrency_array['65'] = new localCurrencyObject('ISK', 'Iceland Krona (ISK)', 'kr');
localcurrency_array['66'] = new localCurrencyObject('INR', 'Indian Rupee (INR)', '₨');
localcurrency_array['67'] = new localCurrencyObject('IDR', 'Indonesian Rupiah (IDR)', 'Rp');
localcurrency_array['68'] = new localCurrencyObject('IRR', 'Iran Rial (IRR)', '﷼');
localcurrency_array['69'] = new localCurrencyObject('IQD', 'Iraqi Dinar (IQD)', '');
localcurrency_array['70'] = new localCurrencyObject('ILS', 'Israeli Shekel (ILS)', '₪');
localcurrency_array['71'] = new localCurrencyObject('JMD', 'Jamaican Dollar (JMD)', '$');
localcurrency_array['72'] = new localCurrencyObject('JOD', 'Jordanian Dinar (JOD)', 'د.ا');
localcurrency_array['73'] = new localCurrencyObject('KZT', 'Kazakhstan Tenge (KZT)', 'лв');
localcurrency_array['74'] = new localCurrencyObject('KES', 'Kenyan Shilling (KES)', 'Sh');
localcurrency_array['75'] = new localCurrencyObject('KWD', 'Kuwaiti Dinar (KWD)', 'د.ك');
localcurrency_array['76'] = new localCurrencyObject('KGS', 'Kyrgyzstan Som (KGS)', 'лв');
localcurrency_array['77'] = new localCurrencyObject('LAK', 'Lao Kip (LAK)', '₭');
localcurrency_array['78'] = new localCurrencyObject('LBP', 'Lebanese Pound (LBP)', '£');
localcurrency_array['79'] = new localCurrencyObject('LSL', 'Lesotho Loti (LSL)', '');
localcurrency_array['80'] = new localCurrencyObject('LRD', 'Liberian Dollar (LRD)', '$');
localcurrency_array['81'] = new localCurrencyObject('LYD', 'Libyan Dinar (LYD)', 'ل.د');
localcurrency_array['82'] = new localCurrencyObject('MOP', 'Macau Pataca (MOP)', 'P');
localcurrency_array['83'] = new localCurrencyObject('MKD', 'Macedonian Denar (MKD)', 'ден');
localcurrency_array['84'] = new localCurrencyObject('MWK', 'Malawi Kwacha (MWK)', 'MK');
localcurrency_array['85'] = new localCurrencyObject('MYR', 'Malaysian Ringgit (MYR)', 'RM');
localcurrency_array['86'] = new localCurrencyObject('MVR', 'Maldives Rufiyaa (MVR)', 'ރ.');
localcurrency_array['87'] = new localCurrencyObject('MRO', 'Mauritania Ougulya (MRO)', 'UM');
localcurrency_array['88'] = new localCurrencyObject('MUR', 'Mauritius Rupee (MUR)', '₨');
localcurrency_array['89'] = new localCurrencyObject('MXN', 'Mexican Peso (MXN)', '$');
localcurrency_array['90'] = new localCurrencyObject('MDL', 'Moldovan Leu (MDL)', '');
localcurrency_array['91'] = new localCurrencyObject('MNT', 'Mongolian Tugrik (MNT)', '₮');
localcurrency_array['92'] = new localCurrencyObject('MAD', 'Moroccan Dirham (MAD)', 'د.م.');
localcurrency_array['93'] = new localCurrencyObject('MZN', 'Mozambique Metical (MZN)', 'MT');
localcurrency_array['94'] = new localCurrencyObject('MMK', 'Myanmar Kyat (MMK)', '');
localcurrency_array['95'] = new localCurrencyObject('NAD', 'Namibian Dollar (NAD)', '$');
localcurrency_array['96'] = new localCurrencyObject('NPR', 'Nepalese Rupee (NPR)', '₨');
localcurrency_array['97'] = new localCurrencyObject('ANG', 'Neth Antilles Guilder (ANG)', 'ƒ');
localcurrency_array['98'] = new localCurrencyObject('NIO', 'Nicaragua Cordoba (NIO)', '$');
localcurrency_array['99'] = new localCurrencyObject('NGN', 'Nigerian Naira (NGN)', '₦');
localcurrency_array['100'] = new localCurrencyObject('KPW', 'North Korean Won (KPW)', '₩');
localcurrency_array['101'] = new localCurrencyObject('NOK', 'Norwegian Krone (NOK)', 'kr');
localcurrency_array['102'] = new localCurrencyObject('OMR', 'Omani Rial (OMR)', 'ر.ع.');
localcurrency_array['103'] = new localCurrencyObject('XPF', 'Pacific Franc (XPF)', 'Fr');
localcurrency_array['104'] = new localCurrencyObject('PKR', 'Pakistani Rupee (PKR)', '₨');
localcurrency_array['105'] = new localCurrencyObject('PGK', 'Papua New Guinea Kina (PGK)', 'K');
localcurrency_array['106'] = new localCurrencyObject('PYG', 'Paraguayan Guarani (PYG)', 'Gs');
localcurrency_array['107'] = new localCurrencyObject('PEN', 'Peruvian Nuevo Sol (PEN)', 'S/.');
localcurrency_array['108'] = new localCurrencyObject('PHP', 'Philippine Peso (PHP)', '₱');
localcurrency_array['109'] = new localCurrencyObject('PLN', 'Polish Zloty (PLN)', 'zł');
localcurrency_array['110'] = new localCurrencyObject('QAR', 'Qatar Rial (QAR)', 'ر.ق');
localcurrency_array['111'] = new localCurrencyObject('RON', 'Romanian New Leu (RON)', 'lei');
localcurrency_array['112'] = new localCurrencyObject('RWF', 'Rwanda Franc (RWF)', 'Fr');
localcurrency_array['113'] = new localCurrencyObject('WST', 'Samoa Tala (WST)', 'T');
localcurrency_array['114'] = new localCurrencyObject('STD', 'Sao Tome Dobra (STD)', 'Db');
localcurrency_array['115'] = new localCurrencyObject('SAR', 'Saudi Arabian Riyal (SAR)', 'ر.س');
localcurrency_array['116'] = new localCurrencyObject('RSD', 'Serbia Dinar (RSD)', 'Дин.');
localcurrency_array['117'] = new localCurrencyObject('SCR', 'Seychelles Rupee (SCR)', '₨');
localcurrency_array['118'] = new localCurrencyObject('SLL', 'Sierra Leone Leone (SLL)', 'Le');
localcurrency_array['119'] = new localCurrencyObject('SGD', 'Singapore Dollar (SGD)', '$');
localcurrency_array['120'] = new localCurrencyObject('SBD', 'Solomon Islands Dollar (SBD)', '$');
localcurrency_array['121'] = new localCurrencyObject('SOS', 'Somali Shilling (SOS)', 'S');
localcurrency_array['122'] = new localCurrencyObject('ZAR', 'South African Rand (ZAR)', 'R');
localcurrency_array['123'] = new localCurrencyObject('KRW', 'South Korean Won (KRW)', '₩');
localcurrency_array['124'] = new localCurrencyObject('LKR', 'Sri Lanka Rupee (LKR)', '₨');
localcurrency_array['125'] = new localCurrencyObject('SHP', 'St Helena Pound (SHP)', '£');
localcurrency_array['126'] = new localCurrencyObject('SDG', 'Sudanese Pound (SDG)', '£');
localcurrency_array['127'] = new localCurrencyObject('SRD', 'Suriname Dollar (SRD)', '$');
localcurrency_array['128'] = new localCurrencyObject('SZL', 'Swaziland Lilageni (SZL)', 'L');
localcurrency_array['129'] = new localCurrencyObject('SEK', 'Swedish Krona (SEK)', 'kr');
localcurrency_array['130'] = new localCurrencyObject('CHF', 'Swiss Franc (CHF)', 'CHF');
localcurrency_array['131'] = new localCurrencyObject('SYP', 'Syrian Pound (SYP)', '£');
localcurrency_array['132'] = new localCurrencyObject('TWD', 'Taiwan Dollar (TWD)', '$');
localcurrency_array['133'] = new localCurrencyObject('TZS', 'Tanzanian Shilling (TZS)', 'Sh');
localcurrency_array['134'] = new localCurrencyObject('THB', 'Thai Baht (THB)', '฿');
localcurrency_array['135'] = new localCurrencyObject('TOP', 'Tonga Pa\'ang (TOP)', '$');
localcurrency_array['136'] = new localCurrencyObject('TTD', 'Trinidad & Tobago Dollar (TTD)', '$');
localcurrency_array['137'] = new localCurrencyObject('TND', 'Tunisian Dinar (TND)', 'د.ت');
localcurrency_array['138'] = new localCurrencyObject('TRY', 'Turkish Lira (TRY)', '₺');
localcurrency_array['139'] = new localCurrencyObject('AED', 'UAE Dirham (AED)', 'د.إ');
localcurrency_array['140'] = new localCurrencyObject('UGX', 'Ugandan Shilling (UGX)', 'Sh');
localcurrency_array['141'] = new localCurrencyObject('UAH', 'Ukraine Hryvnia (UAH)', '₴');
localcurrency_array['142'] = new localCurrencyObject('UYU', 'Uruguayan New Peso (UYU)', '$U');
localcurrency_array['143'] = new localCurrencyObject('UZS', 'Uzbekistan Som (UZS)', 'лв');
localcurrency_array['144'] = new localCurrencyObject('VUV', 'Vanuatu Vatu (VUV)', 'Vt');
localcurrency_array['145'] = new localCurrencyObject('VEF', 'Venezuelan Bolivar Fuerte (VEF)', 'Bs');
localcurrency_array['146'] = new localCurrencyObject('VND', 'Vietnam Dong (VND)', '₫');
localcurrency_array['147'] = new localCurrencyObject('YER', 'Yemen Riyal (YER)', '﷼');
localcurrency_array['148'] = new localCurrencyObject('ZMW', 'Zambian Kwacha (ZMW)', '');
function localCurrencyUserSelection(sitecurrency, usercurrency, postid) {
document.write('<select style="width:200px" name="lc_currency' + postid + '" id="lc_currency' + postid + '" onchange="localCurrencyChange(\'' + sitecurrency + '\',lcValues' + postid + ',' + postid + ')">');
for (var i = 0; i <= localcurrency_array.length - 1; i++) {
document.write('<option value="' + localcurrency_array[i]['id'] + '" ');
if (usercurrency == localcurrency_array[i]['id']) {
document.write('selected="selected"');
}
document.write('>' + localcurrency_array[i]['name'] + '</option>');
}
document.write('</select>');
}
答案 0 :(得分:1)
更正您的功能:
function localCurrencyUserSelection(parentElement, sitecurrency, usercurrency, postid) {
var html = ['<select style="width:200px" name="lc_currency' + postid + '" id="lc_currency' + postid + '" onchange="localCurrencyChange(\'' + sitecurrency + '\',lcValues' + postid + ',' + postid + ')">'];
for (var i = 0; i <= localcurrency_array.length - 1; i++) {
html.push('<option value="' + localcurrency_array[i]['id'] + '" ');
if (usercurrency == localcurrency_array[i]['id']) {
html.push('selected="selected"');
}
html.push('>' + localcurrency_array[i]['name'] + '</option>');
}
html.push('</select>');
var span = document.createElement('span');
span.innerHTML = html.join('');
var newSelect = span.firstChild;
parentElement.appendChild(newSelect);
}
你的功能调用
localCurrencyUserSelection(document.getElementById('myDivThanContainsTheSelect'), ....)