Я пишу программу, которая сохраняет текущий URL по нажатию кнопки (Его для расширения хромо, я хочу, чтобы позволить ПК строителей сохранить URL-адрес их части без миллиона закладок)Функции или кнопки не работают?
HTML:
<!DOCTYPE html>
<html>
<body>
<script type="javascript" src="buttonsact.js">
</script>
<button type="button" onclick="changeCPU()">Change CPU</button><h5 id=CPU>Not Selected Yet</h5>
<button type="button" onclick="changeMOTH()">Change Motherboard</button><h5 id=MOTH id=part>Not Selected Yet</h5>
<button type="button" onclick="changeHARD()">Change Hard Drive</button><h5 id=HARD>Not Selected Yet</h5>
<button type="button" onclick="changeRAM()">Change RAM</button><h5 id=RAM>Not Selected Yet</h5>
<button type="button" onclick="changeGPU()">Change GPU</button><h5 id=GPU>Not Selected Yet</h5>
<button type="button" onclick="changeCASE()">Change Case</button><h5 id=CASE>Not Selected Yet</h5>
<button type="button" onclick="changePOWER()">Change Power Unit</button><h5 id=POWER>Not Selected Yet</h5>
<button type="button" onclick="changeMON()">Change Monitor</button><h5 id=MON>Not Selected Yet</h5>
<button type="button" onclick="reset()">!!!!RESET!!!!</button>
</body>
</html>
Javascript:
function getpage()
{
chrome.tabs.getSelected(null,function(tab) {
var tablink = tab.url;
})
}
function changeCPU()
{
x=document.getElementById("CPU"); // Find the element
x.innerHTML=tablink; // Change the content
}
function changeMOTH()
{
x=document.getElementById("MOTH"); // Find the element
x.innerHTML=tablink; // Change the content
}
function changeRAM()
{
x=document.getElementById("RAM"); // Find the element
x.innerHTML=tablink; // Change the content
}
function changeHARD()
{
x=document.getElementById("HARD"); // Find the element
x.innerHTML=tablink; // Change the content
}
function changeGPU()
{
x=document.getElementById("GPU"); // Find the element
x.innerHTML=tablink; // Change the content
}
function changeCASE()
{
x=document.getElementById("CASE"); // Find the element
x.innerHTML=tablink; // Change the content
}
function changePOWER()
{
x=document.getElementById("POWER"); // Find the element
x.innerHTML=tablink; // Change the content
}
function changeMON()
{
x=document.getElementById("MON"); // Find the element
x.innerHTML=tablink; // Change the content
}
function reset()
{
a=document.getElementById("CPU"); // Find the element
b=document.getElementById("MOTH");
c=document.getElementById("HARD");
d=document.getElementById("RAM");
e=document.getElementById("GPU");
f=document.getElementById("CASE");
g=document.getElementById("POWER");
h=document.getElementById("MON");
a.innerHTML="Not Selected Yet"; // Change the content
b.innerHTML="Not Selected Yet";
c.innerHTML="Not Selected Yet";
d.innerHTML="Not Selected Yet";
e.innerHTML="Not Selected Yet";
f.innerHTML="Not Selected Yet";
g.innerHTML="Not Selected Yet";
h.innerHTML="Not Selected Yet";
}
window.onload = getpage()
Я проверил его, чтобы увидеть, если это было просто что-то о моем коде, чтобы захватить URL, изменив это: a.innerHTML="Not Selected Yet"; // Change the content
этого a.innerHTML="Not Selected Yet Yet"; // Change the content
И ударяя сброс. Это все еще не сработало. Я думаю, что-то о том, как моя программа вызывает функцию. Я действительно начал работать, но я не уверен, как я его изменил. Спасибо!
Можете ли вы опубликовать демо-версию, чтобы воспроизвести проблему? Любая ошибка в консоли? – elclanrs
http://developer.chrome.com/extensions/contentSecurityPolicy.html – jusio