1 How to select all in codebox for phpbb2? Mon Feb 28, 2011 9:15 pm
Exterminator
Registered Member
How to select all in codebox for phpbb2?
Someone success with that? Please help me.
Someone success with that? Please help me.
Gangstar15 wrote:did u tried this?
http://www.webartzforum.com/t2292-select-all-in-codebox
function selectCode(a)
{
// Get ID of code block
var e = a.parentNode.parentNode.getElementsByClass('cont_code')[0];
// Not IE
if (window.getSelection)
{
var s = window.getSelection();
// Safari
if (s.setBaseAndExtent)
{
s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
}
// Firefox and Opera
else
{
// workaround for bug # 42885
if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) == '<BR>')
{
e.innerHTML = e.innerHTML + ' ';
}
var r = document.createRange();
r.selectNodeContents(e);
s.removeAllRanges();
s.addRange(r);
}
}
// Some older browsers
else if (document.getSelection)
{
var s = document.getSelection();
var r = document.createRange();
r.selectNodeContents(e);
s.removeAllRanges();
s.addRange(r);
}
// IE
else if (document.selection)
{
var r = document.body.createTextRange();
r.moveToElementText(e);
r.select();
}
}
if(text){}else{ var text = 'Selecionar todos';}
jQuery(document).ready(function(){
jQuery("td.code").html('Code: <a href="#" onclick="selectCode(this); return false;" title="Select all the content" class="code-a">Select All</a>');
});
jQuery(document).ready(function(){
jQuery("span.genmed").html('Code: <span class="codeselect" onclick="selectCode(this); return false;">Select content</span>');
});
<code></code>
WebArtz - The Web Design Forum » Web Designing & Coding » CSS (Cascading Style Sheets) » How to select all in codebox for phpbb2?
Similar topics
Permissions in this forum:
You cannot reply to topics in this forum
|
|