Select Content
4 posters
Page 1 of 1
Select Content
- Code:
function selectCode(a)
{
// Get ID of code block
var e = jQuery(a).closest('tr').next().find('.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();
}
}
jQuery(function(){
jQuery('div.postbody td.code').parent().prev().find('b').html('Code:
<a href="javascript:void()" onClick="selectCode(this)"><font
face="verdana" color="red"></font> Select Content </a>');
});
https://help.forumotion.com/t93456-select-content-button Followed that, won't work
Edit:Phpbb2 user and Google Chrome. I tried editing it to this:
- Code:
function selectCode(a)
{
// Get ID of code block
var e = jQuery(a).closest('tr').next().find('.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 Google Chrome
else
{
// workaround for bug # 42885
if (window.google chrome && 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();
}
}
jQuery(function(){
jQuery('div.postbody td.code').parent().prev().find('b').html('Code:
<a href="javascript:void()" onClick="selectCode(this)"><font
face="verdana" color="red"></font> Select Content </a>');
});
But won't work
Last edited by Frances Kaizer on October 21st 2012, 8:25 am; edited 1 time in total
Re: Select Content
Try this more up to date tutorial: http://www.avacweb.com/t113-select-code
LGforum- Hyperactive
- Posts : 2265
Reputation : 264
Language : English
Location : UK
Re: Select Content
- Code:
function selectNode(elem) {
var sel, range;
if (window.getSelection && document.createRange) {
sel = window.getSelection();
range = document.createRange();
range.selectNodeContents(elem);
sel.removeAllRanges();
sel.addRange(range);
} else if (document.selection && document.selection.createRange) {
range = document.selection.createRange();
range.moveToElementText(elem);
range.select();
}
};
Where do I put that? ._." And this
- Code:
$(function() {
$('dl.codebox:not(.spoiler) dt').append('<a class="selectCode clearfix" onclick="selectNode(this.parentNode.nextSibling.firstChild)">Select code</a>');
});
All I know where to put is the CSS and yes, erm, about the typo I saw in the comments, where should I remove it? or is it okay with the code already?
Re: Select Content
Create a new Javascript (ACP -> Modules -> Javascript codes management).
☑ In the topics.
☑ In the topics.
Tonight- Forumember
- Posts : 312
Reputation : 80
Language : Estonian, English, Russian
Location : Estonia
Re: Select Content
You can put them in 1 if you want
Doesn't matter actually.
Doesn't matter actually.
Tonight- Forumember
- Posts : 312
Reputation : 80
Language : Estonian, English, Russian
Location : Estonia
Re: Select Content
- Code:
function selectNode(elem) {
var sel, range;
if (window.getSelection && document.createRange) {
sel = window.getSelection();
range = document.createRange();
range.selectNodeContents(elem);
sel.removeAllRanges();
sel.addRange(range);
} else if (document.selection && document.selection.createRange) {
range = document.selection.createRange();
range.moveToElementText(elem);
range.select();
}
};
$(function() {
$('dl.codebox:not(.spoiler) dt').append('<a class="selectCode clearfix" onclick="selectNode(this.parentNode.nextSibling.firstChild)">Select code</a>');
});
And I made sure it's in the topics too. Still won't work
Re: Select Content
Have you done the CSS part too? (Colors -> CSS Stylesheet)
- Code:
.selectCode {
float: right;
cursor: pointer;
}
Tonight- Forumember
- Posts : 312
Reputation : 80
Language : Estonian, English, Russian
Location : Estonia
Re: Select Content
Meh, why'd the select content go to the right part o.O
http://www.medievalchaos.net/t1165-misshingupawa-to-fumetsu-and-remilia-scarelet#5250 Sample
Edit:
Question, how can I make the code box look attractive? I can do the select content now but the code box is ugly
I want to make the text green and select content green, the code white and stuff and add borders or whatever but I don't know where to change it.
http://www.medievalchaos.net/t1165-misshingupawa-to-fumetsu-and-remilia-scarelet#5250 Sample
Edit:
Question, how can I make the code box look attractive? I can do the select content now but the code box is ugly
I want to make the text green and select content green, the code white and stuff and add borders or whatever but I don't know where to change it.
Re: Select Content
It goes to the right because of the bit in the CSS that says this for it: float: right;
Change it to left or remove it.
Change it to left or remove it.
LGforum- Hyperactive
- Posts : 2265
Reputation : 264
Language : English
Location : UK
Re: Select Content
Haha yes probably. But the choice is yours.
LGforum- Hyperactive
- Posts : 2265
Reputation : 264
Language : English
Location : UK
Re: Select Content
Topic Solved & Locked |
Sanket- ForumGuru
- Posts : 48766
Reputation : 2830
Language : English
Location : Mumbai
Similar topics
» "select content"
» Select content
» Code Of " Select Content"
» "Select Content" not working?
» Select Content don't work on my forum
» Select content
» Code Of " Select Content"
» "Select Content" not working?
» Select Content don't work on my forum
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum