Hi, i'm trying to use the divviewer image viewer as found here - http://www.javascriptkit.com/script/script2/divviewer.shtml

but i cant seem to get it to work properly, as seen here -

any ideas please?

Thanks

Dani AI

Generated

Good catch by — the viewer was failing because the image src the script produced was not a valid file path/filename. confirmed that supplying the correct filename and path fixed it. For readers who land here later, the following checklist and notes cover the common causes and practical fixes.

  • Inspect the element with your browser dev tools and confirm the src value shown in the Elements panel.
  • Use the Network panel to see if the image request returns 200 or 404 (and to confirm the correct MIME type).
  • Make sure the filename includes the correct extension (case matters on many servers) and that the path is correct relative to the page or is an absolute URL.
  • Avoid spaces and unsafe characters in filenames. Either rename files to use hyphens/underscores or percent-encode/escape special characters (ampersands should be escaped in HTML attributes).
  • Ensure the viewer script runs after the DOM is ready — initialize the viewer on DOMContentLoaded or place scripts after the markup so the image element exists when the script accesses it.
  • Clear browser cache after changes to be sure you’re testing the latest files.

A common subtlety: older widgets sometimes target the image by a name attribute. Modern HTML prefers id. If the viewer expects name, either leave that attribute in place or update the widget to use id/querySelector for a cleaner, future-proof fix. For reference on image element attributes and DOM load timing, see MDN: img element and DOMContentLoaded event.

Recommended Answers

All 2 Replies

Hi
Seems like the image source is not properly formed.
Set the full image src .. also rename the image

the image tag is formed some thing like this (found with the help of firebug) <img height="130" width="200" border="0" name="picDV" title="" alt="" src="Becky_retouch"/> Expected html should be

<img src="" width="200" height="130" border="0" alt="">

Regards
Anish

Of course!!! omg im such a tard, why didn't i see that?

Mate thanks a ton, works a treat now :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.