HTML, . , HTML-. , .
: -, , , HTML. , inline script 1 "" .;)
live : jsbin.com/agimi5/3.
, <div id="StoryGoesHere">. , :
InsertImageInStory ("StoryGoesHere", 30, "F_left", "Image URL");
:
function InsertImageInStory (ContainID, PercentIn, LeftorRightClass, ImageURL)
{
var storyContainer = $("#" + ContainID);
var storyHTML = storyContainer.html ();
var storyLen = storyHTML.length;
var targetCharPos = (storyLen * PercentIn) / 100;
for (var J = 0, bInTag = false; J < storyLen; ++J)
{
if (storyHTML.charAt(J) == '<' || storyHTML.charAt(J) == '>' )
bInTag ^= true;
if (J < targetCharPos) continue;
if (!bInTag)
{
var newStory = storyHTML.substr (0, J+1);
newStory += '<img src="' + ImageURL + '" class="' + LeftorRightClass + '">';
newStory += storyHTML.substr (J+1, storyLen+1);
storyContainer.html (newStory);
break;
}
}
}
PHP, .
1 inline script, .