Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't dynamic resize IMG after javascript dynamic content load
    primarykey
    data
    text
    <p>I use this javascript from dynamicdrive to load content into a div:</p> <pre><code> var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no) var loadedobjects="" var rootdomain="http://"+window.location.hostname var bustcacheparameter="" function ajaxpage(url, containerid){ var page_request = false if (window.XMLHttpRequest) // if Mozilla, Safari etc page_request = new XMLHttpRequest(); else if (window.ActiveXObject){ // if IE try { page_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e){ try{ page_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){} } } else return false page_request.onreadystatechange=function(){ loadpage(page_request, containerid) } if (bustcachevar) //if bust caching of external page bustcacheparameter=(url.indexOf("?")!=-1)? "&amp;"+new Date().getTime() : "?"+new Date().getTime() page_request.open('GET', url+bustcacheparameter, true) page_request.setRequestHeader('charset', 'ISO-8859-1') page_request.send(null) } function loadpage(page_request, containerid){ if (page_request.readyState == 4 &amp;&amp; (page_request.status==200 || window.location.href.indexOf("http")==-1)) document.getElementById(containerid).innerHTML=page_request.responseText } </code></pre> <p>I use a self written php function called "displayImage('url','width')" to display an image which is then dynamically re-sized to the specified width.</p> <p>This works great on static content, however, the function refuses to work on dynamic content.</p> <p>Can anyone give me a push in the right direction on this one? :/ I'm not so good at javascript...</p> <p>EDIT:</p> <p>Sorry, forgot to add the php function, here it goes:</p> <pre><code>function displayImage($img_path, $height) { $image_info = getimagesize($img_path); $new_dimension = imageResize($image_info[0], $image_info[1], $height); $returnstr = "&lt;IMG SRC=\"{$img_path}\" " . $new_dimension . "/&gt;\n"; return $returnstr; } function imageResize($width, $height, $target) { if ($width &gt; $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); } $width = round($width * $percentage); $height = round($height * $percentage); return "width=\"$width\" height=\"$height\""; </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload