document.body.insertAdjacentHTML - need firefox alternative!
-
- Guest
document.body.insertAdjacentHTML - need firefox alternative!
This is the code used to generate the html box window thing....
---------------------------------------------------------
<SCRIPT>
function XY(e)
{
var x = 0;
var y = 0;
if (e.pageX || e.pageY)
{
x = e.pageX;
y = e.pageY;
}
else if (e.clientX || e.clientY)
{
x = e.clientX + document.body.scrollLeft;
y = e.clientY + document.body.scrollTop;
}
// posx and posy contain the mouse position relative to the document
// Do something with this information
}
function ShowMessage(text,id)
{
var popup;
top_pos = y - 120 + 'px';
left_pos = x -100 + 'px';
document.body.insertAdjacentHTML('BeforeEnd', '<DIV><table>' + text + '</table></DIV>');
}
function Kill(id)
{
id.innerHTML = "";
id.outerHTML = "";
}
</SCRIPT>
---------------------------------------------------------
This code is used on each URL that requires a pop up.
---------------------------------------------------------
<A HREF="game.php?id=2">1830: Railroads & Robber Barons</a>
---------------------------------------------------------
But it doesn't work in Firefox, only IE and Opera.
Is there a way of making this work for Firefox as well?
Please help, thanks in advance.
---------------------------------------------------------
<SCRIPT>
function XY(e)
{
var x = 0;
var y = 0;
if (e.pageX || e.pageY)
{
x = e.pageX;
y = e.pageY;
}
else if (e.clientX || e.clientY)
{
x = e.clientX + document.body.scrollLeft;
y = e.clientY + document.body.scrollTop;
}
// posx and posy contain the mouse position relative to the document
// Do something with this information
}
function ShowMessage(text,id)
{
var popup;
top_pos = y - 120 + 'px';
left_pos = x -100 + 'px';
document.body.insertAdjacentHTML('BeforeEnd', '<DIV><table>' + text + '</table></DIV>');
}
function Kill(id)
{
id.innerHTML = "";
id.outerHTML = "";
}
</SCRIPT>
---------------------------------------------------------
This code is used on each URL that requires a pop up.
---------------------------------------------------------
<A HREF="game.php?id=2">1830: Railroads & Robber Barons</a>
---------------------------------------------------------
But it doesn't work in Firefox, only IE and Opera.
Is there a way of making this work for Firefox as well?
Please help, thanks in advance.
- trolly
- Moderator
- Posts: 39851
- Joined: August 22nd, 2005, 7:25 am
Best to register and ask in the web developer forum. The thread can be moved to that forum.
Think for yourself. Otherwise you have to believe what other people tell you.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.
A society based on individualism is an oxymoron. || Freedom is at first the freedom to starve.
Constitution says: One man, one vote. Supreme court says: One dollar, one vote.
-
- Guest
insertAdjacentHTML simply isn't a supported function. Add this to your script:
// insertAdjacentHTML(), insertAdjacentText() and insertAdjacentElement
()
// for Netscape 6/Mozilla by Thor Larholm me@jscript.dk
// Usage: include this code segment at the beginning of your document
// before any other Javascript contents.
if(typeof HTMLElement!="undefined" && !
HTMLElement.prototype.insertAdjacentElement){
HTMLElement.prototype.insertAdjacentElement = function
(where,parsedNode)
{
switch (where){
case 'beforeBegin':
this.parentNode.insertBefore(parsedNode,this)
break;
case 'afterBegin':
this.insertBefore(parsedNode,this.firstChild);
break;
case 'beforeEnd':
this.appendChild(parsedNode);
break;
case 'afterEnd':
if (this.nextSibling)
this.parentNode.insertBefore(parsedNode,this.nextSibling);
else this.parentNode.appendChild(parsedNode);
break;
}
}
HTMLElement.prototype.insertAdjacentHTML = function
(where,htmlStr)
{
var r = this.ownerDocument.createRange();
r.setStartBefore(this);
var parsedHTML = r.createContextualFragment(htmlStr);
this.insertAdjacentElement(where,parsedHTML)
}
HTMLElement.prototype.insertAdjacentText = function
(where,txtStr)
{
var parsedText = document.createTextNode(txtStr)
this.insertAdjacentElement(where,parsedText)
}
}[/code] http://www.faqts.com/knowledge_base/view.phtml/aid/5756
// insertAdjacentHTML(), insertAdjacentText() and insertAdjacentElement
()
// for Netscape 6/Mozilla by Thor Larholm me@jscript.dk
// Usage: include this code segment at the beginning of your document
// before any other Javascript contents.
if(typeof HTMLElement!="undefined" && !
HTMLElement.prototype.insertAdjacentElement){
HTMLElement.prototype.insertAdjacentElement = function
(where,parsedNode)
{
switch (where){
case 'beforeBegin':
this.parentNode.insertBefore(parsedNode,this)
break;
case 'afterBegin':
this.insertBefore(parsedNode,this.firstChild);
break;
case 'beforeEnd':
this.appendChild(parsedNode);
break;
case 'afterEnd':
if (this.nextSibling)
this.parentNode.insertBefore(parsedNode,this.nextSibling);
else this.parentNode.appendChild(parsedNode);
break;
}
}
HTMLElement.prototype.insertAdjacentHTML = function
(where,htmlStr)
{
var r = this.ownerDocument.createRange();
r.setStartBefore(this);
var parsedHTML = r.createContextualFragment(htmlStr);
this.insertAdjacentElement(where,parsedHTML)
}
HTMLElement.prototype.insertAdjacentText = function
(where,txtStr)
{
var parsedText = document.createTextNode(txtStr)
this.insertAdjacentElement(where,parsedText)
}
}[/code] http://www.faqts.com/knowledge_base/view.phtml/aid/5756
-
- Guest
Re: document.body.insertAdjacentHTML - need firefox alternat
No need for a table element, is there?
Can you provide a link to a working example?
Code: Select all
function ShowMessage(text,id)
{
var popup;
top_pos = y - 120 + 'px';
left_pos = x -100 + 'px';
div = document.createElement('div');
div.innerHTML = text;
document.body.appendChild('div');
}
Can you provide a link to a working example?
-
- Guest
document.body.insertAdjacentHTML('BeforeEnd', '<DIV><table>' + text + '</table></DIV>');
Thats my document.body.insertAdjacentHTML
Each popup is defined by the tracks it'll list "popup<id>" and it complains they're undefined.
It also complains about y being undefined, even though x is done in the same way.
Help meeee !
Thats my document.body.insertAdjacentHTML
Each popup is defined by the tracks it'll list "popup<id>" and it complains they're undefined.
It also complains about y being undefined, even though x is done in the same way.
Help meeee !
-
- Posts: 7
- Joined: August 9th, 2006, 6:04 am
-
- Posts: 0
- Joined: December 31st, 1969, 5:00 pm
Re: document.body.insertAdjacentHTML - need firefox alternat
This doesn't work?
Anonymous wrote:Code: Select all
function ShowMessage(text,id)
{
var popup;
top_pos = y - 120 + 'px';
left_pos = x -100 + 'px';
div = document.createElement('div');
div.innerHTML = text;
document.body.appendChild('div');
}
-
- Posts: 7
- Joined: August 9th, 2006, 6:04 am
http://www.hoverrace.com/tracks/index.p ... wse&type=5
Hover over the links, theres a working example in IE, but it doesn't work in Firefox.
Hover over the links, theres a working example in IE, but it doesn't work in Firefox.
-
- Posts: 0
- Joined: December 31st, 1969, 5:00 pm
Re: document.body.insertAdjacentHTML - need firefox alternat
np wrote:This doesn't work?Anonymous wrote:Code: Select all
function ShowMessage(text,id)
{
var popup;
top_pos = y - 120 + 'px';
left_pos = x -100 + 'px';
div = document.createElement('div');
div.innerHTML = text;
document.body.appendChild('div');
}
-
- Posts: 7
- Joined: August 9th, 2006, 6:04 am
-
- Posts: 0
- Joined: December 31st, 1969, 5:00 pm
In your mouseout events, put popup in single quotes. Change the following functions
and take out the "insertAdjacentHTML(), insertAdjacentText() and insertAdjacentElement()" stuff that the guest above gave you.
Code: Select all
function ShowMessage(text,id)
{
top_pos = y - 120 + 'px';
left_pos = x -100 + 'px';
div = document.createElement('div');
div.setAttribute("id", id);
div.innerHTML = text;
document.body.appendChild('div');
}
function Kill(id)
{
document.body.removeChild(document.getElementById(id));
}
and take out the "insertAdjacentHTML(), insertAdjacentText() and insertAdjacentElement()" stuff that the guest above gave you.
-
- Posts: 7
- Joined: August 9th, 2006, 6:04 am
-
- Posts: 0
- Joined: December 31st, 1969, 5:00 pm
Sorry, had some extra quotes. Change
to
It's still complaining about popup because you didn't change the mouseout events.
Change to
Code: Select all
document.body.appendChild('div');
to
Code: Select all
document.body.appendChild(div);
It's still complaining about popup because you didn't change the mouseout events.
Change
Code: Select all
onmouseout=Kill(popup)
Code: Select all
onmouseout="Kill('popup')"