hi all, so I was trying to make a flower identification app using a service by bing and Java Script, so there is an option in this website that we can search images by URL of the image. as an example, I am using this image and i am using this code document.getElementsByTagName('span')[12].textContent;
to get the name of the flower
when I try this code in the console of the website it works well
URL used in my blockly code :https://www.bing.com/visualsearch/Microsoft/FlowerIdentification?&imgurl=https://i.ibb.co/PDshQYf/391126cd-977a-43c7-9937-4f139623cd58.jpg
JavaScript code used in my blockly code : - document.getElementsByTagName('span')[12].textContent;
can someone guide me on where I am going wrong
and I am making this project for learning purpose only
Yes something like that should work. Try to paste your code in evaluate js block.
In my project I have my own created html so i just write in js evaluate (for example) FlowerName(); as i could add the function to javascript code in html file in other words i get my return value just by calling the function name.
function FlowerName() {
return document.getElementsByTagName('span')[12].textContent;
};
FlowerName()
Im not fluent in javascript (i just used basics of js for my project) and i don’t know if u can call document.getelement in function without argument or variable.
If it doesn’t work you can try different setup like:
var x = document.getElementsByTagName('span')[12].textContent;
function FlowerName(x) {
return x;
};
FlowerName()
or
function FlowerName() {
return x;
};
FlowerName()
I tried it as well in firefox. Your definied element in my webviewer is not a flower name. Your element definition must be unprecise. Remember that every webviewer engine works differently.