http_set_request_crossorigin

With this function you can set the cross origin type to use when loading images from a file (using sprite_add()), or sending custom HTTP requests to servers (e.g. using http_post_string()). The function is exclusively for the HTML5 platform.

When set to "use-credentials" you no longer need to give an absolute path to the sprite being loaded, but instead would give a relative path (as shown in the example below).

By default the cross origin type is set to "anonymous".

 

Syntax:

http_set_request_crossorigin(origin_type);

ArgumentTypeDescription
origin_typeStringThe cross origin type to use (a string)

 

Returns:

N/A

 

Example:

if (string_lower(http_get_request_crossorigin()) != "use-credentials")
{
    http_set_request_crossorigin("use-credentials");
}
sprite_add("sprites/player_outfit_1.png", 0, false, false, 0, 0);

The above code will first check the currently set cross origin type and if it is not "use-credentials" then it is set to "use-credentials" and then a sprite is added from a file.