Enjoy an ad free experience by logging in. Not a member yet?
Register .
09-07-2012, 11:05 PM
PM User |
#1
New Coder
Join Date: Sep 2012
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
document object works in IE but not in FF
Hi Guys,
The following snippet works perfectly in IE. I can't get code below to work in FF. The code returns file path and path when saved and opened as html file.
Thanks for your help.
<html>
<body>
cmCreatePageviewTag("<<label id="myDiv1"></label>>","<<label id="myDiv2"></label>>");
<script type="text/javascript">
var myDiv1 = document.getElementById("myDiv1");
var myDiv2 = document.getElementById("myDiv2");
myDiv1.innerText = window.location.pathname;
var path = top.location.pathname;
if (document.all) {
path = path.replace(/\\/g,"/");
}
path = path.substr(0,path.lastIndexOf("/"));
var full_path = path;
myDiv2.innerText = full_path;
</script>
</body>
</html>
09-08-2012, 12:32 AM
PM User |
#2
Senior Coder
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 454 Times in 452 Posts
I would try with
Code:
myDiv1.innerHTML = window.location.pathname;
myDiv2.innerHTML = full_path;
09-08-2012, 04:07 PM
PM User |
#3
New Coder
Join Date: Sep 2012
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks xelawho for your reply. I had that exact experssion previously, didn't make a difference. You'll see if you save as html file then open in url window. Still trying to solve but any help is welcome.
09-08-2012, 05:12 PM
PM User |
#4
Senior Coder
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 454 Times in 452 Posts
using innerHTML I get the same output in IE, FF and Chrome...
09-08-2012, 05:48 PM
PM User |
#5
New Coder
Join Date: Sep 2012
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Yeah you right works on my home pc, strange I think I tried on my work computer and it didn't work. Thanks for your help. I will confirm and reply when I go to work Monday.
09-09-2012, 02:15 PM
PM User |
#6
New Coder
Join Date: Sep 2012
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Guys,
Is there a way to get the value of the output html to show within the same page view source, without hardcoding it inside the javascript?
I need to be able to produce this value in multiple individual pages.
Thank for any help or suggestions.
09-10-2012, 04:17 AM
PM User |
#7
New Coder
Join Date: Sep 2012
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Basically I want to be able to show result of output html in view source, below as an eg:
cmCreatePageviewTag("</C:/Users/Test/Documents/test.html>","</C:/Users/Test/Documents/>");
09-10-2012, 06:24 PM
PM User |
#8
New Coder
Join Date: Sep 2012
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Guys I get the below code to work in IE, but not in FF. Any ideas getting it to work in FF?
Code:
<html>
<head>
cmCreatePageviewTag("<<label id="myDiv1"></label>>","<<label id="myDiv2"></label>>");
<script language="javascript">
<!-- works in IE only -->
function WriteToFile()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var s = fso.CreateTextFile("C:\\Text.txt", true);
document.getElementById("myDiv1").innerHTML = window.location.pathname;
document.getElementById("myDiv2").innerHTML = top.location.pathname.replace(/\\/g,"/").replace( /\/[^\/]*$/, "/" );
s.WriteLine('<script language=\"javascript\"\>');
s.WriteLine("cmCreatePageviewTag(\"<" + window.location.pathname + "," + top.location.pathname.replace(/\\/g,"/").replace( /\/[^\/]*$/, "/" ) + ">\")");
s.WriteLine('\</script\>');
s.Close();
}
</script>
</head>
<body onLoad="WriteToFile()">
</body>
</html>
09-10-2012, 06:28 PM
PM User |
#9
Senior Coder
Join Date: Nov 2010
Location: Salem,Ma
Posts: 1,307
Thanks: 12
Thanked 204 Times in 204 Posts
no, because it uses activex objects which are exclusive to IE
09-22-2012, 01:31 PM
PM User |
#10
New Coder
Join Date: Sep 2012
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks Guys for your response. How do I replace \ with : in code below. Try it in code below but it's not working.
Code:
cmCreatePageviewTag("<<label id="myDiv1"></label>>","<<label id="myDiv2"></label>>");
<script type="text/javascript">
document.getElementById("myDiv1").innerHTML = window.location.pathname;
document.getElementById("myDiv2").innerHTML = top.location.pathname.replace(/\\/g,":").replace( /\/[^\/]*$/, ":" );
alert("cmCreatePageviewTag(\"<" + window.location.pathname + "," + top.location.pathname.replace(/\\/g,":").replace( /:[^:]*$/, ":" ) + ">\")");
</script>
09-23-2012, 02:10 PM
PM User |
#11
New Coder
Join Date: Sep 2012
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Nevermind guys I got it working, here is the solution below plus uppercase function:
Code:
cmCreatePageviewTag("<<label id="myDiv1"></label>>","<<label id="myDiv2"></label>>");
<script type="text/javascript">
document.getElementById("myDiv1").innerHTML = window.location.pathname.split('/').join(':').toUpperCase();
document.getElementById("myDiv2").innerHTML = top.location.pathname.replace(/\\/g,"/").replace( /\/[^\/]*$/, "" ).split('/').join(':').toUpperCase();
</script>
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 03:39 PM .
Advertisement
Log in to turn off these ads.