views:

27

answers:

2
$(document).ready(function () {
//create the div
var div = $("<div></div>").css("position", "absolute").text("a short message").appendTo("body");



//attach the mousemove event
$("body").bind('mousemove', function(evt) {
    div.css({
        "left": evt.pageX + "px",
        "top": evt.pageY + "px"
    });
});

});

what im trying to do is replace a short message with an iframe, what do i do?

A: 

Instead of .text, use .html and put the HTML for your iframe there.

I'm curious what your use case for this is, though.

justkt
thanks for the response, however that just makes a link to the url, not the page in an iframe.
sam
What code did you use in your `.html` call? An iframe?
justkt
i just have this in my site at the moment, but i need it to relevant to the mouse cursor, <iframe src="http://www.mysite.com/example overflow:hidden; width:400px; height:21px;" allowTransparency="true"></iframe>
sam
@sam - If you give that `iframe` a unique `id` and set $("#id").css, or put it in a `.html` that's on your `div` variable, it should work. You'll probably also want to raise the iframe's `z-index` in this case.
justkt
A: 

Thanks for your suggestion, im not sure what you mean

Do i give my iframe an id like this?

iframe id ="exampleframe" src="http://www.mysite.com/example&amp;width=400&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:400px; height:21px;" allowTransparency="true" /iframe

then I put var div = $("exampleframe").css("position", "absolute").text("a short message").appendTo("body");

?

i also created a file called exampleframe.html, when i navigate to it, it shows what I want, but when i put var div = $("").css("position", "absolute").html("exampleframe.html").appendTo("body");

i just get the text exampleframe.html as a link to the url,

Sam