Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8931409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:06:36+00:00 2026-06-15T09:06:36+00:00

function loadNextComic() { window.scrollTo( 200, 480); img comic = new Image(); currentComicNumber++; comic.src=Freqpg+currentComicNumber+.jpg; comic.onload

  • 0
function loadNextComic()
{
window.scrollTo( 200, 480);
img comic = new Image();
    currentComicNumber++;
    comic.src="Freqpg"+currentComicNumber+".jpg";
    comic.onload = function()
        {
        document.getElementById("comic").src="Freqpg"+currentComicNumber+".jpg";
        document.getElementById("numberOutput").innerHTML=currentComicNumber;
        }
    comic.onerror =lastComicReached();


}

This code is intended to iterate a webcomic page. If the next page exists, it should load, and once loaded, display. If the page doesn’t exist, the code should call another function, as this indicates we have probably reached the end of the archive. Unfortunately, this code does nothing at all. Even the scroll function breaks.

function loadNextComic()
{
window.scrollTo( 200, 480);
//img comic = new Image();
    currentComicNumber++;
    //comic.src="Freqpg"+currentComicNumber+".jpg";
    //comic.onload = function()
    //  {
        document.getElementById("comic").src="Freqpg"+currentComicNumber+".jpg";
        document.getElementById("numberOutput").innerHTML=currentComicNumber;
    //  }
    //comic.onerror =lastComicReached();


}

This code with the img code commented out progresses the pages correctly until of course I run out of pages (which are consecutively and reliably named), and seeing as how this number will change weekly, I can’t simply hard code the last page number. I tried using the img.onerror and onload code after looking at other examples on the site. Clearly I’ve been fumbling like an idiot with this. I’ve read in a few places about asynchronous execution breaking onerror, but I thought this should have accounted for that.

How do I get the img.onload and onerror functions to work? How do you do structured programming if the code executes asynchronously?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:06:37+00:00Added an answer on June 15, 2026 at 9:06 am

    You need to declare them BEFORE you change the src

    Also you are REPLACING the onerror, and therefore you need to remove the () unless lastComicReached returns a function

    Lastly img comic is not valid syntax, you mean var comic

    var comic = new Image(); 
    comic.onload = function() {
      document.getElementById("comic").src="Freqpg"+currentComicNumber+".jpg";
      document.getElementById("numberOutput").innerHTML=currentComicNumber;
    }
    comic.onerror =lastComicReached; // remove the () here!!
    comic.src="Freqpg"+currentComicNumber+".jpg";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function controllaFoto(target, username) { var _URL = window.URL || window.webkitURL; var img = new
function getWindowsUserName() { var WinNetwork = new ActiveXObject(WScript.Network); var urlToSite = createCustomURL(WinNetwork.UserName); document.getElementById(psyncLink).src =
function has_thumbnail_image(&$post) { $content = $post->post_content; return preg_match('/<img[^>]+src=(.*?)[^>]*>/', $content, $results); } I need a
function all_images(&$post){ $content = $post->post_content; if(preg_match_all('/<img[^>]+src=(.*?)[^>]*>/', $content, $results)){ $i = 0; $count = count($results);
function Apple(){ this.name=apple; } function Orange(){ this.name=orange; this.apple = new Apple(); this.apple.onCalled=function(){ alert(this.name); }
function getWindowsUserName() { var WinNetwork = new ActiveXObject(WScript.Network); var urlToSite = http://localhost/index.php?nph-psf=0&HOSTID=AD&ALIAS= + WinNetwork.UserName;
function initialize() { var myOptions = { center: new google.maps.LatLng(23.71181,90.407467), zoom: 8, mapTypeId: google.maps.MapTypeId.ROADMAP
function Person(name){ this.name = name; } p = new Person('John'); log(typeof p.constructor); var f
function updateOption(selection, option) { jQuery('body,html').animate({ scrollTop: jQuery(#msg).offset().top }, 800); jQuery('.'+selection).each(function() { jQuery(img.+selection).removeClass(optionSelected); }); jQuery.ajax({
function parseAttach(b) { var h=; for(i=0;i<b.length;i++) { var a=b[i]; switch(a['type']) { case image: h+='<li

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.