lo dicho niños, alguien q sepa como sacar el width y el height de una imagen proporcionada mediante un link????
Y alguien a kien se le ocurra q poner en mi codigo para q rule en mozilla?
pego el codigo completo, q ya lo tengo terminadito ^^=
Código HTML:
<html>
<head>
<script type="text/javascript">
var sel;
function setSelection()
{
var texto;
if (document.selection)
{ // for IE
sel = document.selection.createRange().text;
}
else if (typeof document.getElementById("mbody").value.selectionStart != 'undefined')
{ // for FF, Opera etc...
sel = document.getElementById("mbody").value.substring(document.getElementById("mbody").value.selectionStart, document.getElementById("mbody").value.selectionEnd);
}
}
function editFontStyle(style)
{
if (sel == null)
{
document.getElementById("mbody").value = document.getElementById("mbody").value + "";
}
else
{
var formatSel = "[" + style + "]" + sel + "[/" + style + "]";
document.getElementById("mbody").value = document.getElementById("mbody").value.replace(sel, formatSel);
}
sel = null;
}
function editFontSize()
{
if (sel == null)
{
document.getElementById("mbody").value = document.getElementById("mbody").value + "";
}
else
{
var formatSel = "[SIZE=" + document.formNewMsg.size.value + "]" + sel + "[/SIZE]";
document.getElementById("mbody").value = document.getElementById("mbody").value.replace(sel, formatSel);
}
sel = null;
}
function editFontColor()
{
if (sel == null)
{
document.getElementById("mbody").value = document.getElementById("mbody").value + "";
}
else
{
var formatSel = "[COLOR=" + document.getElementById("color").value + "]" + sel + "[/COLOR]";
document.getElementById("mbody").value = document.getElementById("mbody").value.replace(sel, formatSel);
}
sel = null;
}
function insertQuote()
{
var name = prompt("Cita de:", "");
if (name == null)
{
name = "";
}
if (sel == null)
{
document.getElementById("mbody").value = document.getElementById("mbody").value + "";
}
else
{
var formatSel = "[QUOTE=" + name + "]" + sel + "[/QUOTE]";
document.getElementById("mbody").value = document.getElementById("mbody").value.replace(sel, formatSel);
}
sel = null;
}
function insertLink()
{
var textToAdd;
var link = prompt("Url de la web:", "h t t p: / /");
if ((link != null) && (link != "h t t p: / /"))
{
if (sel == null)
{
var linkName = prompt("Nombre de la web:", "");
if (linkName == null)
{
linkName = link;
}
textToAdd = "[U R L=" + link + "]" + linkName + "[/ U R L]";
document.getElementById("mbody").value = document.getElementById("mbody").value + " " + textToAdd;
}
else
{
var linkName = prompt("Nombre de la web:", sel);
if (linkName == null)
{
linkName = link;
}
textToAdd = "[U R L=" + link + "]" + linkName + "[/ U R L]";
document.getElementById("mbody").value = document.getElementById("mbody").value.replace(sel, textToAdd);
}
}
sel = null;
}
function insertImg()
{
var textToAdd;
var img = prompt("Url de la imagen:", "h t t p: / /");
if ((img != null) && (img != "h t t p: / /"))
{
if (img.width>100)
{
var scale = (100 * 100) / img.width;
var new_width = (img.width * scale) / 100;
var new_height = (img.height * scale) / 100;
texttoAdd = "[IMG=" + new_width + "x" + new_height + "]" + img + "[/IMG]";
document.getElementById("mbody").value = document.getElementById("mbody").value + " " + textToAdd;
}
}
sel = null;
}
</script>
</head>
<body>
<form name="formNewMsg">
<INPUT type="button" name="bold" value="B" onClick="editFontStyle('B')" />
<INPUT type="button" name="bold" value="I" onClick="editFontStyle('I')" />
<INPUT type="button" name="bold" value="U" onClick="editFontStyle('U')" />
<SELECT name="color" onChange="editFontColor()">
<OPTION value=""></OPTION>
<OPTION value="black">Negro</OPTION>
<OPTION value="gray">Gris</OPTION>
<OPTION value="brown">Marrón</OPTION>
<OPTION value="darkblue">Azul oscuro</OPTION>
<OPTION value="blue">Azul</OPTION>
<OPTION value="cyan">Celeste</OPTION>
<OPTION value="darkgreen">Verde oscuro</OPTION>
<OPTION value="olive">Oliva</OPTION>
<OPTION value="green">Verde</OPTION>
<OPTION value="purple">Morado</OPTION>
<OPTION value="violet">Violeta</OPTION>
<OPTION value="fucsia">Fucsia</OPTION>
<OPTION value="pink">Rosa</OPTION>
<OPTION value="darkred">Rojo oscuro</OPTION>
<OPTION value="red">Rojo</OPTION>
<OPTION value="orange">Naranja</OPTION>
<OPTION value="gold">Oro</OPTION>
<OPTION value="yellow">Amarillo</OPTION>
<OPTION value="white">Blanco</OPTION>
</SELECT>
<SELECT name="size" onChange="editFontSize()">
<OPTION value=""></OPTION>
<OPTION value="6">Pequeña</OPTION>
<OPTION value="10">Normal</OPTION>
<OPTION value="18">Grande</OPTION>
<OPTION value="32">Enorme</OPTION>
<OPTION value="45">Gigante</OPTION>
</SELECT>
<INPUT type="button" name="cita" value="Cita" onClick="insertQuote()" />
<INPUT type="button" name="link" value="Link" onClick="insertLink()" />
<INPUT type="button" name="img" value="Imagen" onClick="insertImg()" />
<BR>
<textarea name="mbody" rows=5 cols=50 onMouseUp="setSelection()"></textarea>
<BR>
<INPUT onClick="document.write(document.getElementById('mbody').value)" type="button" name="boton" value="Vista Previa" />
<INPUT onClick="document.getElementById('mbody').value=''" type="button" name="boton" value="Borrar" />
</form>
</body>
</html>
PD: no se puede? pues ese codigo de chekeo lo sake de este foro, creo recordar, lo q si es verdad es q no funciona... afú, q dificil esta esto TT.TT
PD2: En php se podria hacer? o.o