|
|
|
Yazan
|
Konu: Javascript - Link ekleme Fonksiyonu hakkında (Okunma Sayısı 260 defa)
|
|
kertenkele
|
Selam arkadaşlar, Elimde hazır bir kod var RTE isimli yazma paneline ait. Burada resim ekleme fonksiyonu mevcut. Resmi ekliyor bir sorun yok fakat üzrinde bir değişiklik yapmak istiyorum. Resmi eklerken resme link eklemesini istiyorum. İnsert fonksiyonu şu şekilde ; function insertImageFunction() { imagePath = "http://" + document.getElementById('urlImage').value; window.opener.document.getElementById(rte).contentWindow.focus(); window.opener.document.getElementById(rte).contentWindow.document.execCommand('InsertImage', false, imagePath); window.close(); }
imagepathe link ekletmek istiyorum. Nasıl olacak bir fikrim yok. Java konusunda çok acemiyim..
|
|
|
|
|
Logged
|
|
|
|
|
tiamat
|
Birdocument.getElementById('urlImage')["onclick"]= Function(" location.href='link'; "); İki document.getElementById('urlImage').onclick = function(){ location.href='link'; }; İkisinden biri olur büyük ihtimalle.
|
|
|
|
|
Logged
|
Tuvalete oturmadan önce, Musluğunu kontrol et bence
|
|
|
|
kertenkele
|
ikiside olmadı. hata veriyor sayfa.
|
|
|
|
|
Logged
|
|
|
|
|
tiamat
|
Yukarıda yazdığımı aşağıdaki kodda denedim çalışıyor  <html> <head> <script type="text/javascript" language="JavaScript"> function deneme(){ document.getElementById('deneme').onclick = function(){ location.href='sil.html'; }; } </script> <title></title> </head> <body onload="deneme();"> <img id="deneme" src="turkbc_5/gui/img/index/delete2.gif"> </body> </html>
|
|
|
|
|
Logged
|
Tuvalete oturmadan önce, Musluğunu kontrol et bence
|
|
|
|
kertenkele
|
verdiğim fonksiyonun içerisinde " imagePath = "http://" + document.getElementById('urlImage').onclick = function(){ location.href='link'; }; " şeklinde yazdım. yani; function insertImageFunction() { imagePath = "http://" +document.getElementById('urlImage').onclick = function(){ location.href='link'; }; window.opener.document.getElementById(rte).contentWindow.focus(); window.opener.document.getElementById(rte).contentWindow.document.execCommand('InsertImage', false, imagePath); window.close(); }
şeklinde. Sayfa hiç açılmadı kodun tamamı; <script language='JavaScript' type='text/javascript'>
var aNameValuePair = location.search.substring(1,location.search.length).split("&"); var aParam = new Array(aNameValuePair.length); for ( var i=0; i<aNameValuePair.length; i++ ) { param = aNameValuePair[i].split("="); aParam[param[0]] = aParam[i] = { name: param[0], value: unescape(param[1].replace('+', ' ')) }; } language = aParam[0].value; rte = aParam[1].value;
// document.writeln('<title>Resim Bulucu</title>'); sentenceTitle = "Resmin bulundugu adres"; sentenceInsert = "Resmi gördügünüz zaman, üzerine tiklayarak yaziya dahil edebilirsiniz.";
document.writeln('<div class=rowPopup> </div>'); document.writeln('<div class=rowPopup>' + sentenceTitle + '</div>'); document.writeln('<div class=rowPopup>' + sentenceInsert + '</div>'); document.writeln('<div class=rowPopup> </div>'); document.writeln('<div class=rowPopup>'); document.writeln(' <span class=labelPopup>http://</span>'); document.writeln(' <span class=fieldPopup><input name="urlImage" id="urlImage" type="text" size="70" onKeyUp="updateImageFunction()"></span>'); document.writeln('</div>'); document.writeln('<div class=rowPopup> </div>'); document.writeln('<div class=rowPopup><img name="imagePreview" src="" style="visibility:hidden;cursor:pointer;cursor:hand" onClick="insertImageFunction()"></div>'); document.getElementById('urlImage').focus();
function insertImageFunction() { imagePath = "http://" +document.getElementById('urlImage').onclick = function(){ location.href='link'; }; window.opener.document.getElementById(rte).contentWindow.focus(); window.opener.document.getElementById(rte).contentWindow.document.execCommand('InsertImage', false, imagePath); window.close(); }
function updateImageFunction() { document.imagePreview.style.visibility = "hidden"; document.imagePreview.onload = imageLoaded; document.imagePreview.src = "http://" + document.getElementById('urlImage').value; }
function imageLoaded() { document.imagePreview.style.visibility = "visible"; } </script>
|
|
|
|
|
Logged
|
|
|
|
|
tiamat
|
Hemen imagePath = ... satırının arkasına yani aşağıdaki gibi dene. function insertImageFunction() { var urlImage = document.getElementById('urlImage'); imagePath = "http://" + urlImage.value; urlImage.onclick = function(){ location.href='sil.html'; }; window.opener.document.getElementById(rte).contentWindow.focus(); window.opener.document.getElementById(rte).contentWindow.document.execCommand('InsertImage', false, imagePath); window.close(); }
|
|
|
|
|
Logged
|
Tuvalete oturmadan önce, Musluğunu kontrol et bence
|
|
|
|
 |
|