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 7089059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:52:34+00:00 2026-05-28T07:52:34+00:00

function controllaFoto(target, username) { var _URL = window.URL || window.webkitURL; var img = new

  • 0
function controllaFoto(target, username) {
    var _URL = window.URL || window.webkitURL;
    var img = new Image();
    img.onload = function () {
        if(this.width > 240 || this.height > 240) {
            document.getElementById("photoLabel").innerHTML = "Text";
            document.getElementById("preview").setAttribute("src", "profile?to=showImage&username="+username);
            target.value = "";
        } else {
            document.getElementById("photoLabel").innerHTML = "";
            document.getElementById("preview").setAttribute("src", this.src);
        }
    };
    img.src = _URL.createObjectURL(target.files[0]);
    return true;
}

This script is called by the onchange and onsubmit attributes and works fine in Firefox and Chrome, but not in Opera and Safari. The event onload is not triggered. Why?

UPDATE I’m testing it with Windows.

UPDATE 2 The problem is that _URL is undefined. I tried with

var _URL = window.URL || window.webkitURL || window.mozURL || window.msURL || window.oURL;

but still not working.

For Chrome its value is object DOMURL, for Firefox is object MozURLProperty, but for Safari and Opera is undefined. So the console says:

Uncaught exception: TypeError: Cannot convert ‘_URL’ to object

  • 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-05-28T07:52:35+00:00Added an answer on May 28, 2026 at 7:52 am

    According to this MDN page, it doesn’t look like createObjectURL is supported in Opera or in some versions of Safari. That alone may be your main issue. Have you looked in the error console to see if it’s complaining about the lack of the createObjectURL method. If that method doesn’t exist, you would never get an assignment to .src so thus there would never be a successful load event.

    In addition, I can’t say for sure, but this also looks like a potential issue to me. You may need to store the newly create Image object somewhere so it persists. The way your code is written above, the garbage collector may be free to dispose of the img object because there are no longer any references to it.

    Perhaps you haven’t shown us all of your code, but as you have it written, what’s the point of loading an image that you will never use?

    So, I’d suggest either change the way your code works to not use an image that you aren’t going to use. Or, actual store the newly create img tag somewhere so it persists and won’t get garbage collected.

    I’d also ask how you know that the image is loading successfully? If you’re not using the image, how do you know it’s successfully loading.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function Person(name){ this.name = name; } p = new Person('John'); log(typeof p.constructor); var f
function selected() { var selObj = window.getSelection(); } This function returns selected text from
function check(id){ var _id = document.getElementById(id); url = test.php?check=1&id= + _id; } i want
function logsig() { var username = $(#username).val(); var password = $(#password).val(); var dataString =
function getUsername() { var userName = document.form.screen_name.value; document.getElementById(display).innerHTML = userName; var apiName = https://api.twitter.com/1/users/lookup.json?screen_name=
function genTask(elem){ elem.each(function(){ $this=$(this).parent('.cntTasks'); var pattern=/taskId-(.*)$/ var idTask=$this.attr('id').match(pattern); var data='id_task='+idTask[1]; if(typeof jsVar2 !='undefined') data+=jsVar2;
function doSomething(e) { var targ; if (!e) var e = window.event; //<<<< what does
Function.prototype.bind = function(){ var fn = this, args = Array.prototype.slice.call(arguments), object = args.shift(); return
function ajaxCall(query){ $.ajax({ method:get, url:/main/, data:q=+query, beforeSend:function() {}, success:function(html){ $(#main).html(html); } }); }; This
function change_star_image(star_id){ //$(#star_rating_image_+star_id).css(background-image,url(images/full-star.png)); $(#star_rating_image_+star_id).css('background', 'url(images/full-star.png)'); } The background image is not changed. The above

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.