Развернуть скрытый DIV при загрузке шАкфьу
Вложений: 2
Есть вот такая страница: http://pixels.com/widgetshoppingcart...oheight=tru e
вверху имеем переключатели меню: самый правый - Galleries. Если его нажать, разворачивается скрытый DIV. А можно ли прилепить какой код свержу, чтобы страница грузилась сразу с открытыми галереями? Грузиться будет в iFrame, т.е. на материнскую страницу можно прилепить любой кастом CSS и javascript. DIV оформлен с помощью скрипта, в теле страницы тоже имеется скрипт с функциями, явно относящимися к делу. Прилагается. Описание DIV, который хочется разветнут при загрузке: <div class="customdropdowncontainer"> <p>Galleries</p> <div id="dropdowngalleries" class="customdropdownselected" onclick="javascript: showoptions("galleries");"> <p>All</p> <div> <img src="https://fineartamerica.com/images/ArrowDownCustomDropDown.png"> </div> </div> </div> Обратите внимание: а) это один из серии блоков, совершенно одинаковых по тэгам, разница только в тексте внутри <p> и в мини-самом скрипте - showoptions("galleries") Скрипт в теле загружаемой страницы (по-моему, искомая часть начинается со строки 094): function newHttpReq() { var newRequest = null; try { newRequest = new XMLHttpRequest(); } catch(trymicrosoft) { try { newRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch(othermicrosoft) { try { newRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch(failed) { newRequest = null; } } } return newRequest; } var image001 = new Image(); image001.src = 'http://fineartamerica.com/Searching.gif'; var thispage = "artwork.html?memberidtype=artistid&memberid=223022&domainid=0&showheader=0&sessionid=523ecdb9e1b2e004c4aeac681950a9ab&flagwidget=true&widgettype=standard&product=all&tag=all&medium=all&galleryname=all"; var flagcolorselected = false; var request = newHttpReq(); var httpobject = []; httpobject[-1] = newHttpReq(); var backgroundobject; var sourceobject; var targetobject; var requestcount = 0; if(!httpobject[-1]) { alert("Error Initializing XMLHttpRequest!"); } function scrollmainiframelocal() { var message = "scrollmainiframe();"; parent.postMessage(message,'*'); } function resizemainiframelocal() { // [url]http://stackoverflow.com/questions/1145850/how-to-get-height-of-entire-document-with-javascript[/url] var body = document.body; var html = document.documentElement; var height = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight); height = height + 40; var message = "resizemainiframe(" + height + ");"; parent.postMessage(message,'*'); } function checkwidgetkeywords() { var widgetkeywords = document.getElementById('widgetkeywords').value; if(widgetkeywords == 'search') { document.getElementById('widgetkeywords').value = ''; document.getElementById('widgetkeywords').style.fontColor = '#444444'; } } function clearbody() { document.getElementById('bodysearchengine').innerHTML = "<div style='float: left; width: 100%; height: 100%; background-color: #000000;'><p style='width: 80%; margin: auto; padding-top: 15px; font: 10pt arial; text-align: center; color: #FFFFFF;'>This features is only available to premium members. If you would like to use this widget, please upgrade to a <a href='http://fineartamerica.com/controlpanel/index.html?tab=printondemand' target='_blank' style='font: 10pt arial; color: #FFFFFF; text-decoration: underline;'>premium account</a>.</p></div>"; } var lastsourcediv = ''; var lastsourcedropdown = ''; var lastsourcedropdownclassname = ''; function showoptions(optionname) { if(lastsourcediv != '') { document.getElementById('hiddendivscontainer').appendChild(lastsourcediv); } var sourcedropdown = document.getElementById('dropdown' + optionname); var sourcediv = document.getElementById('hidden' + optionname + 'div'); var targetdiv = document.getElementById('messagediv'); targetdiv.appendChild(sourcediv); if(lastsourcedropdownclassname != '') { lastsourcedropdown.className = lastsourcedropdownclassname; } if(sourcediv != lastsourcediv) { targetdiv.style.display = 'none'; } else { } if(targetdiv.style.display == 'none') { if(sourcedropdown.className != 'customdropdownselected') { lastsourcedropdownclassname = sourcedropdown.className; } sourcedropdown.className = 'customdropdownselected'; targetdiv.innerHTML = sourcediv.innerHTML; targetdiv.style.display = 'inline-block'; if(optionname == 'colors') { showcolorcharttop(thispage); } } else { targetdiv.style.display = 'none'; } lastsourcediv = sourcediv; lastsourcedropdown = sourcedropdown; } function showcolorcharttop(currenturl) { var localvalue = requestcount; var poststring = 'action=showcolors¤turl=' + encodeURIComponent(currenturl); document.getElementById('messagediv').innerHTML = "<img src='http://fineartamerica.com/Searching.gif' style='display: inline-block; padding-top: 25px; padding-bottom: 25px;'>"; document.getElementById('messagediv').style.display = 'inline-block'; httpobject[localvalue] = newHttpReq(); httpobject[localvalue].onreadystatechange = function(){ try { if(httpobject[localvalue].readyState == 4) { } if(httpobject[localvalue].status == 200) { } } catch (e) { return; } if(httpobject[localvalue].readyState == 4 && httpobject[localvalue].status == 200) { document.getElementById('messagediv').innerHTML = httpobject[localvalue].responseText; } }; var url = '../queries/querysearchenginecolorcharttop.php'; httpobject[localvalue].open('post',url,true); httpobject[localvalue].setRequestHeader("content-type", "application/x-www-form-urlencoded"); httpobject[localvalue].send(poststring); requestcount += 1; } function highlightcolortop(targetcolorid,targetcolor) { //alert(targetcolorid + ' - ' + targetcolor); document.getElementById(targetcolorid + 'topdiv').style.backgroundImage = 'none'; document.getElementById(targetcolorid + 'topdiv').style.backgroundColor = targetcolor; } function selectcolortop(targetcolorid,targetcolor,targeturl) { flagcolorselected = true; document.getElementById(targetcolorid + 'topdiv').style.backgroundColor = targetcolor; document.getElementById(targetcolorid + 'topchartdiv').innerHTML = "<img src='http://fineartamerica.com/Searching.gif' style='display: inline-block'>"; window.location = targeturl; } function showdimensionsapplychangestop() { document.getElementById('dimensionsapplychangestopdiv').style.display = 'inline-block'; } function dimensionsapplychangestop(currenturl) { var minimumprintwidth = document.getElementById('minimumprintwidthtop').value; var minimumprintheight = document.getElementById('minimumprintheighttop').value; if(minimumprintwidth > 50 && minimumprintheight > 50) { alert('Both dimensions can not exceed 48". Please reduce one of your dimensions to less than 48".'); return; } //var newurl = currenturl + '?minimumprintwidth=' + minimumprintwidth + '&minimumprintheight=' + minimumprintheight + '&maximumprintwidth=' + maximumprintwidth + '&maximumprintheight=' + maximumprintheight; var newurl = currenturl + '&minimumprintwidth=' + minimumprintwidth + '&minimumprintheight=' + minimumprintheight; window.location = newurl; } Как открывается по умолчанию, и как хотелось бы: |
пробовал вот так:
<script> var iframe = document.getElementsByTagName('iframe')[0]; function showoptions(galleries){ iframe.onload = showoptions(); }; </script> не ругается, но и не работает :( предполагаю, потому, что скрипт, к которому надо обратиться, грузится с другого домена в iFrame и доступа к нему сраружи iFrame нету? |
Krakozavr,
Цитата:
Galleries не справа, а слева в столбце, и при нажатии ничего не происходит. Или уже что-то изменили? Во всяком случае, вариант решения проблемы: В head поместить генератор события click на нужный вам элемент $(window).on('load', function () { $(yourElementSelect).trigger('click'); }); (Вместо yourElementSelect подставить нужное, вроде ".sidebarheader") |
Dilettante_Pro,
внешний вид зависит от ширины экрана. На большом экране список галерей появляется действительно слева в столбце, но при этом основная панель управления - выглядяшая как выпадающие списки полосой, вверху над картинками - никуда не пропадает, и переключатель галерей там на своем месте - крайний справа. Но предварительно - видимо, сделать это невозможно, потому что эта страница грузится со внешнего домена в iFrame, а значит, никакой код с материнской страницы доступа к ней иметь не должен. Или ест способы это обойти? :) |
Krakozavr,
Да, кроссдоменно не разрешает... |
Часовой пояс GMT +3, время: 08:16. |