搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

Learn More

Need help in checking the dom node position for different screen resoultions

  • 1 回覆
  • 1 有這個問題
  • 10 次檢視
  • 最近回覆由 FredMcD

more options

Hi,

We are working on an Open Source Chrome extension: Digital Assistant Client

I am recording the domnode by converting into json by domJson and saving into server. We can find the same recordednode by comparing the json attributes and matching to the original node on the page. We have one problem here when we search for the nodes sometimes we get similar nodes via json which has same property names. In that case we are trying to match the node position that we have recorded. When we try to match the node position in different screen resolutions, it gives us the wrong node. How do we solve this. My code is as given below

// calculate distance between selected node and matching node getDistance: function (node1, node2) {

  const x = node1.x - node2.x;
  const y = node1.y - node2.y;
  const dist = Math.abs(Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)));
  return dist;

},

Hi, We are working on an Open Source Chrome extension: [https://github.com/kcramakrishna/Digital_Assistant_Client Digital Assistant Client] I am recording the domnode by converting into json by domJson and saving into server. We can find the same recordednode by comparing the json attributes and matching to the original node on the page. We have one problem here when we search for the nodes sometimes we get similar nodes via json which has same property names. In that case we are trying to match the node position that we have recorded. When we try to match the node position in different screen resolutions, it gives us the wrong node. How do we solve this. My code is as given below // calculate distance between selected node and matching node getDistance: function (node1, node2) { const x = node1.x - node2.x; const y = node1.y - node2.y; const dist = Math.abs(Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))); return dist; },

所有回覆 (1)

more options

Add-on questions should be posted in the add-ons forum; https://discourse.mozilla-community.org/c/add-ons