我需要你帮我处理一下兰西图书馆的事。
如何在iframe选定内容中应用rangy,我无法理解((
我的页面中的这段代码创建了带有所有iframe内容的红色粗体选择,但我只需要将它应用于用户选择
var cssApplier;
$("#ok_button").click(function()
{
var iframe = document.getElementById("iframe_id");
var iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
var range = rangy.createRange(iframeDoc);
cssApplier.applyToRange(range);
});
$("iframe#iframe_id").load(function()
{
rangy.init();
cssApplier = rangy.createCssClassApplier("boldRed", {normalize: true});
});发布于 2012-07-27 07:22:36
您需要从iframe中获取选择。下面是操作步骤:
var cssApplier;
$("#ok_button").click(function()
{
var iframe = document.getElementById("iframe_id");
var iframeWin = rangy.dom.getIframeWindow(iframe);
cssApplier.applyToSelection(iframeWin);
// In Rangy 1.3, you can pass the iframe object directly into
// applyToSelection so the previous two lines become:
// cssApplier.applyToSelection(iframe);
});
$("iframe#iframe_id").load(function()
{
rangy.init();
cssApplier = rangy.createCssClassApplier("boldRed", {normalize: true});
});https://stackoverflow.com/questions/11674027
复制相似问题