|
Member 14695956 wrote: <script src="/Scripts/jquery-1.10.2.js"></script>
My guess, yuor jQuery version is quite old. Try latest and see. Current version: Download jQuery | jQuery
Quick check try:
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
Also, make sure reference to bootstrap JavaScript is after jquery file reference.
|
|
|
|
|
Hi Thanks for your reply I needed to keep this version of Jquery due to the fact that I am using signalr and I could only get it to work with this version. I have found a work around by not using jquery-confirm.min.js as this seems to also conflict. and use a Modal form as my alert box. May not be the neatest but it works.
|
|
|
|
|
Hi,
I am almost new with javascript.
I finally succeeded to write the foundation of a small javascript game but I am blocked at one point.
My question is simple: how can I call the function quitGame() from outside the Game() function?
[code]
var settings = "blablah";
new Game(settings);
...
quitGame(settings)
var Game = function(settings) {
...
function quitGame(settings) {
...
}
} [/code]
I would be thankful for any help or comment about my code.
I wish you a pleasant lockdown, stay safe
|
|
|
|
|
|
Working with objects - JavaScript | MDN[^]
The simplest option:
var Game = function(settings) {
...
this.quitGame = function(settings) {
...
}
};
var settings = "blablah";
var game = new Game(settings);
...
game.quitGame(settings);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Is there a way to get the extension of an image if you know it's link? At first I thought of splitting the string with . and get the last part, but the problem with this is that there are some links that don't include the extension at the end so this is not an universal solution.
Because I know the link each time, is there something I can do with an image object (new Image), or how else can I get the extension? All the results I got were to check if it is an image but not it's extension, or the one I explained above, but that won't work in every scenarios.
This will be done in a extension for Firefox.
modified 9-Nov-20 16:23pm.
|
|
|
|
|
mebbe something like...
file = url.split('/').pop();
|
|
|
|
|
Unfortunately like I said, there are some website where the file name and the extensions is not included into the link, so there is nothing to split to get them.
But even then, if you use the built-in "Save Image As...", the browser still knows what those are, so there has to be a way to do it.
|
|
|
|
|
|
Richard Deeming wrote:
To read this from Javascript, either the image will need to be on the same domain as your page, or the remote domain will need to set the CORS headers to allow your site to request the image.
Because this will not work in Javascrip with all websites which we actually need, in what other language can it be done?
I do apologies, web applications is not what I normally do, but this time I have to do it and learn for the future, maybe I'll run into something similar.
|
|
|
|
|
You'd have to write something on the server - eg: ASP.NET, PHP, etc. Basically, any server-side language that can make a HEAD request and read the headers from the response.
For example, in C#:
public static async Task<string> GetContentType(HttpClient client, string url)
{
if (string.IsNullOrEmpty(url)) throw new ArgumentNullException(nameof(url));
if (!Uri.TryCreate(url, UriKind.Absolute, out var uri)) throw new ArgumentException("Invalid URL", nameof(url));
using (var request = new HttpRequestMessage(HttpMethod.Head, uri))
using (var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead))
{
response.EnsureSuccessStatusCode();
return response.Content.Headers.ContentType.MediaType;
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
We don't have any control over the server, this is goin to be done in a extension for Firefox. We added a new contextMenu for images only, and from that we can get the Url, but as I said in the first thread there are some websites that don't add the name and the extension directly into the link (example.com/image.jpg / example.com/someImage), so we need to find another way to get them when the user right click's on it.
|
|
|
|
|
Once again, there may not be an image extension. You will have to use the content type.
It looks like it is possible to request extra permissions to your extension to bypass CORS restrictions for certain domains:
permissions - Mozilla | MDN[^]
But it may be easier to intercept the network requests from your extension:
Intercept HTTP requests - Mozilla | MDN[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: But it may be easier to intercept the network requests from your extension:
Intercept HTTP requests - Mozilla | MDN[^]
I'll try this and see if I manage to make something using it. I first thought this whole thing will be something easy.
|
|
|
|
|
Hello all,
I would like to ask you for a help. I would like make a function for add a class. For interactive map. It means there will be a few segments and ONCLICK will be ADD CLASS.
I used this code:
function myFunction() {
document.getElementById("praha").className = "show";
} It works, but only for 1st segment.
I would like to use something like OR. I tried this:
function myFunction() {
document.getElementById("praha").className = "show"; ||
document.getElementById("stredniCechy").className = "show";
} or
function myFunction() {
document.getElementById("praha"||"stredniCechy").className = "show";
} But both of them doesnt works... Could someone give me an advice and help me with it ?
Many thanks
|
|
|
|
|
Those statements do not make sense, as there is no condition test. You first need to add a test to decid which one is required, somthing like:
eltname = (<condition test goes here>) ? "praha" : "stredniCechy";
document.getElementById(eltname).className = "show";
The condition test is whatever you use to decide which name to use.
|
|
|
|
|
Hi, I've created a small library for declaring Maps, WeakMaps or maps-like arrays. Maybe someone will find it useful.
https://www.npmjs.com/package/jsman
https://github.com/mothgears/jsman
|
|
|
|
|
This is a Javascript based Q&A forum. In case you want to share your work, would suggest you to submit it as Your GitHub Project on CodeProject with details about how it is useful and can be used. Follow the guidelines and submit, it will showcase as other articles for people to read.
With current message, most will not be able find what you want to share and will be lost. Thanks!
|
|
|
|
|
This alghoritm i want to use to create shape for cnc foam cutter ... so a one line need to pass all countour paths
for example:
i have 4 path with x,y points coordonates
path1=[[5,3][3,2][8,9][8,8][7,3]]
path2=[[1,9][8,4][3,6]]
path3=[[8,3][4,7][1,2][2,7][4,2][7,5]]
path4=[[4,3][1,7][9,7][8,0]]
Alghoritm need to find in primis a most low value apropriate to 0 in this case [1,2] that is in path3 point 3
After find this point...compare all points of path3 with points of all paths and find most appropiate value ... in this case [8,4] from path2 that is closest to [8,2] from path3
after find most apropiate value ...join the path3 with path 2 in pointers find
result_path=[[0,0]->[1,2][2,7][4,2][7,5]->[8,3]->[8,4][3,6]->[1,9]->[4,7]]
And after join path2 with path3 in this mode ... compare all points of result_path with points of remainder paths (path1,path4) ... and insert path find in result_path in same mode
I dont know how explain better!
|
|
|
|
|
Is this a Javascript question or are you just looking for a generic algorithm? If the latter then please use the correct forum at Algorithms Discussion Boards[^].
|
|
|
|
|
i put this post also in algoritms ... but ... message closed!!!
|
|
|
|
|
You should post it in one place only.
|
|
|
|
|
I am trying to make an add-on for Mozilla Firefox that will convert an image (from a given direct link) to another format and then give the user the save file pop-up.
I have tried to use JavaScript to turn the image into a canvas, and then the canvas to an image with the format wanted, but I run into the problem with canvas.toDataURL, that doesn't allow to use an image from another origin, and I get Uncaught DOMException: The operation is insecure. How else can I do this image conversion? I know it is possible to do it, because there are other add-ons that do this, but my add-on will have other specific functions for our work beside only image conversion, and we can't use those because of that.
I'm doing the testing in straight HTML, because it is easier to do it this way, then keep refreshing the add-on in browser.
Here is the code:
<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
</head>
<body>
<script>
window.onload = function() {
var image = new Image();
image.addEventListener("load", imageLoaded, false);
image.src = "theLinkToAnImage";
};
function imageLoaded() {
var canvas = document.createElement("canvas");
canvas.width = this.width;
canvas.height = this.height;
canvas.getContext("2d").drawImage(this, 0, 0);
var image = new Image();
image.crossOrigin = "Anonymous";
image.src = canvas.toDataURL("image/jpg");
document.body.appendChild(image);
}
</script>
</body>
</html>
modified 27-Oct-20 6:59am.
|
|
|
|
|
Thank you for taking the time to review my question.
I am using Google Maps API and custom JScript to be able to calculate snow loads in Tahoe Basin.
This all works as expected except for one county...El Dorado, which does not work and I have not been able to isolate the issue.
Working Page Here: http:
***NOTE: works perfectly except for Eldorado County (South Shore Lake Tahoe) Click and you will see this error:
ERROR: The address provided appears to be in El_Dorado County county (only Placer, Washoe, Nevada, El Dorado, and Douglas counties are supported)
This is the catch-all error for when someone clicks outside of the supported area.
I can upload the JScript file if helpful...
Thanks Again, I am stumped as to how to address this error. matt
|
|
|
|
|
I'm trying to read multiple matching values of an xpath expression from an xml file in an array in Nashorn Javascript. I'm using javax.xml.xpath classes inside Nashorn to parse xml data. I'm able to read the first matching value just fine when I pass, XPathConstants.STRING to the evaluate function.
alist = xpath.evaluate(exp, input, XPathConstants.NODESET); System.out.println(alist.item[0].getNodeValue());
Its throwing this error - javax.script.ScriptException: TypeError: Cannot read property "getNodeValue" from undefined in
Any ideas why the list would have all null valued elements?
|
|
|
|
|