When I try to load URLs it works without problems, but unfortunately not when I specify the local path can someone help me here?
function fileurl_read() { // save the url for the next time var storage_fileurl = input_fileurl_value.value localStorage.setItem(localstorage_key_data_name, storage_fileurl); if (storage_fileurl (storage_fileurl)) { getJSON(storage_fileurl, function(err, data) { document.getElementById('textarea_json').value = err ? JSON.stringify(err) : JSON.stringify(data, null, 2); if (!err && data) { chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) { fill_form_now(tabs[0]); }); } } ); } else if (storage_fileurl) { alert('Invalid URL'); } } /* File url read */ var input_fileurl_value = document.getElementById('input_fileurl'); let button_fill_form_from_url = document.getElementById('button_fill_form_from_url'); button_fill_form_from_url.onclick = function() { fileurl_read(); } function getJSON(url, callback) { var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'json'; xhr.onload = function() { var status = xhr.status; if (status === 200) { callback(null, xhr.response); } else { callback(status, xhr.response); } }; xhr.send(); }; This one is /* */ out.
function isValidHttpUrl(string) { let url; try { url = new URL(string); } catch (_) { return false; } return url.protocol === "http:" || url.protocol === "https:"; } Thanks for the future help.
I tried to load a path instead of an url Example: file:///C:/Users/Demo/Desktop/Doener/data/Test.json
chrome://extensions, 2. clickdetailsof your extension, 3. enable "file access"permissionsin manifest.json includefile://*/or<all_urls>.