Reputation:
When they click on THEATER it should change to NORMAL with a new function in place
example from:
<div id="links">
<a onClick="refreshStream()" onmouseover="color:red;" style="cursor: pointer;" draggable="false" oncontextmenu="return false;"> REFRESH</a>
<a onClick="TheaterMode()" onmouseover="color:red;" style="cursor: pointer;" draggable="false" oncontextmenu="return false;"> THEATER</a>
</div>
TO:
<div id="links">
<a onClick="refreshStream()" onmouseover="color:red;" style="cursor: pointer;" draggable="false" oncontextmenu="return false;"> REFRESH</a>
<a onClick="normalsize()" onmouseover="color:red;" style="cursor: pointer;" draggable="false" oncontextmenu="return false;"> NORMAL</a>";
</div>
I tried this but it didn't work hopefully someone can help thank you.
<script>
document.getElementById("links").innerHTML = "<a onClick="refreshStream()" onmouseover="color:red;" style="cursor: pointer;" draggable="false" oncontextmenu="return false;"> REFRESH</a><a onClick="normalsize()" onmouseover="color:red;" style="cursor: pointer;" draggable="false" oncontextmenu="return false;"> NORMAL</a>";
</script>
Upvotes: 2
Views: 1125
Reputation: 2125
I simplified your example a bit. Basically you'll either need to wrap the html you're assigning in .innerHTML = ...
with single quotes, or use \
to escape the quotes.
Simplified example:
// escape quotes with backslash
function theaterMode() {
document.getElementById("links").innerHTML = "<a onclick=\"refreshStream()\" style=\"cursor: pointer;\"> REFRESH</a><a onclick=\"normalSize()\" style=\"cursor: pointer;\"> NORMAL</a>";
}
// or wrap HTML with single quotes
function normalSize() {
document.getElementById("links").innerHTML = '<a onclick="refreshStream()" style="cursor: pointer;"> REFRESH</a><a onclick="theaterMode()" style="cursor: pointer;"> THEATER</a>';
}
function refreshStream() {
document.getElementById("links").innerHTML = "<a onclick=\"refreshStream()\" style=\"cursor: pointer;\"> REFRESH</a><a onclick=\"normalSize()\" style=\"cursor: pointer;\"> NORMAL</a>";
}
<div id="links">
<a onclick="refreshStream()" style="cursor: pointer;"> REFRESH</a>
<a onclick="theaterMode()" style="cursor: pointer;"> THEATER</a>
</div>
There are cleaner ways to do this, and if you're only changing what the second link does then there's really no reason to keep updating the first link.
Hope that's helpful.
Upvotes: 1