![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 6 Pomógł: 0 Dołączył: 11.05.2008 Skąd: Łódź Ostrzeżenie: (0%) ![]() ![]() |
Mam niemały problem.. Jak większość tu ludzi (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
Kod js: Kod function OpenWindow(url, headerText, contentText ) { var windowStyle = Array( 'width: 50%;', 'height: 50%;', 'top: 100px; ', 'left: 100px; ', 'border: 1px solid #000; ', 'position: absolute; ', 'z-index: 100; ', 'background-color:#ede9e3;' ); var headStyle = Array( 'background-color: #468bcc;', 'border-top: 1px solid #7cb6ec;', 'border-left: 1px solid #7cb6ec;', 'height: 22px; ', 'border-right: 1px solid #3c72a5;', 'border-bottom: 1px solid #3c72a5;', 'margin: 0;', 'text-align:center;', 'color:#fff;', 'font-weight:bold;', 'cursor:move;' ); var contStyle = Array( 'border-left:1px solid #fff;', 'border-right:1px solid #d6cec3;', 'border-top:1px solid #eaeaea;', 'margin:0; ' ); var domDoc=Sarissa.getDomDocument(); var layer=domDoc.createElement('div'); var style=''; for(var i=0;i<windowStyle.length;i++) style+=windowStyle[i]; layer.setAttribute('style',style); layer.setAttribute('class','window'); var old=document.getElementsByClassName('window'); var thisId=old.length+1; layer.setAttribute('id','window'+thisId); domDoc.appendChild(layer); var head=domDoc.createElement('div'); var style=''; for(var i=0;i<headStyle.length;i++) style+=headStyle[i]; head.setAttribute('style',style); var header=domDoc.createElement('h2'); header.setAttribute('style','float:left; clear:left;margin: 2px auto 2px 5px; '); var h2Text=domDoc.createTextNode(headerText); header.appendChild(h2Text); var buttons=domDoc.createElement('div'); buttons.setAttribute('style','float:right; clear:right; margin: 2px 2px 1px auto; ') var closeButton=domDoc.createElement('img'); closeButton.setAttribute('onmouseover','this.src="../img/close_over.gif";'); closeButton.setAttribute('onmouseout','this.src="../img/close.gif";'); closeButton.setAttribute('onclick','CloseWindow('+thisId+');'); closeButton.setAttribute('src','../img/close.gif'); closeButton.setAttribute('alt','Zamknij okno'); closeButton.setAttribute('style','cursor:pointer;'); buttons.appendChild(closeButton); head.appendChild(header); head.appendChild(buttons); var cont=domDoc.createElement('div'); var style=''; for(var i=0;i<contStyle.length;i++) style+=contStyle[i]; cont.setAttribute('style',style); // var escapeContentText=contentText.replace(/</, '&#lt;'); // var contText=domDoc.createTextNode(escapeContentText); // var contText=new XMLSerializer().serializeToString(contentText) // cont.appendChild(document.createTextNode('a \u003cbr /\u003e sdads')); var contText=domDoc.createTextNode(contentText); cont.appendChild(contText); layer.appendChild(head); layer.appendChild(cont); var str=new XMLSerializer().serializeToString(domDoc); document.getElementById('layersContainer').innerHTML=str; mint.fx.Round('window'+thisId); new Draggable('window'+thisId); } Kod jest wywoływany po kliknieiu elementu i wywołuje dropowalne okno na nowej warstwie. Problem jest w okolicach zakomentowanych linijek pod koniec funkcji (to moje kombinacje). Mianowicie - gdy w zmiennej przetrzymującej zawartość tekstową okna (var contentText) umieszczam jakiekolwiek znaczniki HTML nie sa one parsowane, jedynie wyświetlane. Rozumiem że problem jest przez użycie createTextNode(), ale jak to "obejść" ? (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) Ten post edytował webcitrn 12.08.2008, 13:17:37 |
|
|
![]()
Post
#2
|
|
Grupa: Przyjaciele php.pl Postów: 2 258 Pomógł: 16 Dołączył: 21.09.2004 Skąd: Kielce Ostrzeżenie: (0%) ![]() ![]() |
Jak wskazuje nazwa createTextNode stworzy tekst, nie element struktury. Użyj createElement, albo innerHTML.
|
|
|
![]()
Post
#3
|
|
Grupa: Zarejestrowani Postów: 300 Pomógł: 32 Dołączył: 31.07.2006 Ostrzeżenie: (0%) ![]() ![]() |
Albo tworzysz kolejne węzły , odpowiadające twojemu kodowi HTML, podobnie jak to jest to wyżej robione dla elementu IMG - albo szukasz funkcji/hacka która zrobi to automatycznie - powstało takich kilka w związku z niedziałaniem document.write w xhtmlu, np. http://www.poradnik-webmastera.com/artykul...e_i_adsense.php - widziałem gdzieś ładniejszą/ krótszą wersje, ale akurat teraz nie mogę znaleźć :/
|
|
|
![]() ![]() |
![]() |
Aktualny czas: 7.10.2025 - 10:35 |