Advertisement:

Author Topic: Preview post not working with javascript enabled on New Posts  (Read 4429 times)

Offline abda53

  • Semi-Newbie
  • *
  • Posts: 35
I need some help. I am having the EXACT issue as another member, except this is not using a portal.

The preview does not work in NEW POST only, but it works in pm, edits, replies, etc.

It does work if I rename/delete the script.js but I lose more functionality so that is not an option.

If I disable javascript, it works normally.

I am also using the newest version, NO bridges. I tried using a clean updated script.js but its the same as what I have.

I also get this error when I try to do a preview with javascript enabled.
Error: XMLDoc.getElementsByTagName("smf")[0] has no properties

When I try to do a preview, it says
Preview post
Fetching preview...

Any idea?

Offline Rumbaar

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,805
  • Gender: Male
  • Inherent Omniscience
    • Rumbaar.net
Re: Preview post not working with javascript enabled on New Posts
« Reply #1 on: April 06, 2008, 04:55:33 AM »
Firstly can you link to your forum, it will be hard to troubleshoot/fix without seeing it in action.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

Offline abda53

  • Semi-Newbie
  • *
  • Posts: 35
Re: Preview post not working with javascript enabled on New Posts
« Reply #2 on: April 06, 2008, 05:01:19 AM »
Sorry. www.buy established websites.com/forum (remove spaces) I did do some testing on a clean install in another directory and it is working there, so there is something causing it to break, im guessing either how it is integrated into the design, or another mod, but it does not give any php errors, just the javascript error i mentioned

Offline Rumbaar

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 15,805
  • Gender: Male
  • Inherent Omniscience
    • Rumbaar.net
Re: Preview post not working with javascript enabled on New Posts
« Reply #3 on: April 06, 2008, 05:09:50 AM »
Nice integration into an overall website there.  Not sure if they might be causing it.  There isn't really any way to test it in the CORE theme and without that overall site integration I guess?

How about xml_topic.js when you are in the posting area, though I'm not 100% sure if that plays a factor?  Can't test that part without and account :)
« Last Edit: April 06, 2008, 05:12:30 AM by Rumbaar »
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

Offline abda53

  • Semi-Newbie
  • *
  • Posts: 35
Re: Preview post not working with javascript enabled on New Posts
« Reply #4 on: April 06, 2008, 05:11:47 AM »
Thanks!

When I changed it back to the core theme, it was still doing the same thing... which lead me to believe it was a mod, but I know that a lot of other people are having the exact same issue, but noone has yet to pinpoint it.

Offline greyknight17

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 14,890
  • Gender: Male
    • Kevin's Resource Center
Re: Preview post not working with javascript enabled on New Posts
« Reply #5 on: April 07, 2008, 03:42:43 PM »
Do you have any javascript codes that you might have inserted in the the SMF files? They may be throwing things off here and causing problems....

Offline abda53

  • Semi-Newbie
  • *
  • Posts: 35
Re: Preview post not working with javascript enabled on New Posts
« Reply #6 on: April 07, 2008, 03:45:02 PM »
no.

When i disable javascript, it works perfectly, by doing a page refresh (just like on reply previews), and not using ajax. is there a way to disable the javascript feature for previews, and make it always do a refresh?

Offline abda53

  • Semi-Newbie
  • *
  • Posts: 35
Re: Preview post not working with javascript enabled on New Posts
« Reply #7 on: April 09, 2008, 03:33:17 AM »
Does anyone know of a way to disable the ajax feature on autoreply for new posts and private messages?

Offline abda53

  • Semi-Newbie
  • *
  • Posts: 35
Re: Preview post not working with javascript enabled on New Posts
« Reply #8 on: April 14, 2008, 02:21:15 AM »
Anyone? This can't be too hard can it?

Offline greyknight17

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 14,890
  • Gender: Male
    • Kevin's Resource Center
Re: Preview post not working with javascript enabled on New Posts
« Reply #9 on: April 14, 2008, 11:15:12 AM »
I don't think you should disable this. If there's a error somewhere you should fix it and not hide it ;)

Do you remember if you made any changes recently before this problem showed up? What mods do you have installed?

Offline abda53

  • Semi-Newbie
  • *
  • Posts: 35
Re: Preview post not working with javascript enabled on New Posts
« Reply #10 on: April 14, 2008, 04:13:24 PM »
I can either spend hours troubleshooting it, or spend 5 minutes implementing a fix.

Quite a few people have this same error, it's an issue that noone has been able to find the  cause. I need this working now, if a fix is found in the future I will fix it.


Thanks..

Offline abda53

  • Semi-Newbie
  • *
  • Posts: 35
Re: Preview post not working with javascript enabled on New Posts
« Reply #11 on: April 23, 2008, 02:14:25 AM »
I pretty much patched it for now.

/Themes/default/Post.template.php
around lines 40-90

change

Code: [Select]
function previewPost()
{
if (window.XMLHttpRequest)
{', $context['browser']['is_firefox'] ? '
// Firefox doesn\'t render <marquee> that have been put it using javascript
if (document.forms.postmodify.elements["message"].value.indexOf("[move]") != -1)
{
return submitThisOnce(document.forms.postmodify);
}' : '', '
// Opera didn\'t support setRequestHeader() before 8.01.
if (typeof(window.opera) != "undefined")
{
var test = new XMLHttpRequest();
if (typeof(test.setRequestHeader) != "function")
return submitThisOnce(document.forms.postmodify);
}
// !!! Currently not sending poll options and option checkboxes.
var i, x = new Array();
var textFields = ["subject", "message", "icon", "guestname", "email", "evtitle", "question", "topic"];
var numericFields = [
"board", "topic", "num_replies",
"eventid", "calendar", "year", "month", "day",
"poll_max_votes", "poll_expire", "poll_change_vote", "poll_hide"
];
var checkboxFields = [
"ns",
];

for (i in textFields)
if (document.forms.postmodify.elements[textFields[i]])
x[x.length] = textFields[i] + "=" + escape(textToEntities(document.forms.postmodify[textFields[i]].value.replace(/&#/g, "&#38;#"))).replace(/\+/g, "%2B");
for (i in numericFields)
if (document.forms.postmodify.elements[numericFields[i]] && typeof(document.forms.postmodify[numericFields[i]].value) != "undefined")
x[x.length] = numericFields[i] + "=" + parseInt(document.forms.postmodify.elements[numericFields[i]].value);
for (i in checkboxFields)
if (document.forms.postmodify.elements[checkboxFields[i]] && document.forms.postmodify.elements[checkboxFields[i]].checked)
x[x.length] = checkboxFields[i] + "=" + document.forms.postmodify.elements[checkboxFields[i]].value;

sendXMLDocument(smf_scripturl + "?action=post2" + (current_board ? ";board=" + current_board : "") + (make_poll ? ";poll" : "") + ";preview;xml", x.join("&"), onDocSent);

document.getElementById("preview_section").style.display = "";
setInnerHTML(document.getElementById("preview_subject"), txt_preview_title);
setInnerHTML(document.getElementById("preview_body"), txt_preview_fetch);

return false;
}
else
return submitThisOnce(document.forms.postmodify);
}

to

Code: [Select]
function previewPost()
{
';
/*
if (window.XMLHttpRequest)
{', $context['browser']['is_firefox'] ? '
// Firefox doesn\'t render <marquee> that have been put it using javascript
if (document.forms.postmodify.elements["message"].value.indexOf("[move]") != -1)
{
return submitThisOnce(document.forms.postmodify);
}' : '', '
// Opera didn\'t support setRequestHeader() before 8.01.
if (typeof(window.opera) != "undefined")
{
var test = new XMLHttpRequest();
if (typeof(test.setRequestHeader) != "function")
return submitThisOnce(document.forms.postmodify);
}
// !!! Currently not sending poll options and option checkboxes.
var i, x = new Array();
var textFields = ["subject", "message", "icon", "guestname", "email", "evtitle", "question", "topic"];
var numericFields = [
"board", "topic", "num_replies",
"eventid", "calendar", "year", "month", "day",
"poll_max_votes", "poll_expire", "poll_change_vote", "poll_hide"
];
var checkboxFields = [
"ns",
];

for (i in textFields)
if (document.forms.postmodify.elements[textFields[i]])
x[x.length] = textFields[i] + "=" + escape(textToEntities(document.forms.postmodify[textFields[i]].value.replace(/&#/g, "&#38;#"))).replace(/\+/g, "%2B");
for (i in numericFields)
if (document.forms.postmodify.elements[numericFields[i]] && typeof(document.forms.postmodify[numericFields[i]].value) != "undefined")
x[x.length] = numericFields[i] + "=" + parseInt(document.forms.postmodify.elements[numericFields[i]].value);
for (i in checkboxFields)
if (document.forms.postmodify.elements[checkboxFields[i]] && document.forms.postmodify.elements[checkboxFields[i]].checked)
x[x.length] = checkboxFields[i] + "=" + document.forms.postmodify.elements[checkboxFields[i]].value;

sendXMLDocument(smf_scripturl + "?action=post2" + (current_board ? ";board=" + current_board : "") + (make_poll ? ";poll" : "") + ";preview;xml", x.join("&"), onDocSent);

document.getElementById("preview_section").style.display = "";
setInnerHTML(document.getElementById("preview_subject"), txt_preview_title);
setInnerHTML(document.getElementById("preview_body"), txt_preview_fetch);


echo '

return false;
}
else
*/
echo '
return submitThisOnce(document.forms.postmodify);
}

Basically you are just commenting out the AJAX function.

If you want to remove it completely use the following

Code: [Select]
function previewPost()
{
return submitThisOnce(document.forms.postmodify);
}
« Last Edit: April 23, 2008, 02:17:02 AM by abda53 »

Offline metallica48423

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,842
  • Gender: Male
  • Professional Multislacker!
    • Zentendo
Re: Preview post not working with javascript enabled on New Posts
« Reply #12 on: May 15, 2008, 02:34:55 AM »
were you ever able to resolve this?

Code: [Select]
<link rel="shortcut icon" href="/favicon.ico" >

<table width="700"  border="0" align="center" cellpadding="0" cellspacing="0">
 
 <tr>
   <td>

<style>
body{
margin:00px;
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
line-height: 15px;
color: #353535;
/* background-color:#4B4B4B; */
background-color:#d9d9d9;
/* text-align:center; */
}
.navigation { float:left;display:block; width:148px !important; width /**/:149px;text-align:center;border-right: 1px solid #b5b6b7; height:47px !important; height /**/:51px; background:#edf4f7 url(img/menu-bg.gif) top left repeat-x;margin:0 2px;}
.navigationlast{float:left;display:block; width:148px !important; width /**/:149px;text-align:center;border-right: 1px solid #b5b6b7; height:47px !important; height /**/:51px; background:#edf4f7 url(img/menu-bg.gif) top left repeat-x;margin:0 2px; border-right:1px transparent;}
.navigation a {
  display:block;
  padding-top:12px;
  width:100%;height:35px !important; height /**/:51px;
  font-size:11px;font-weight:bold; color:#7f7f7f;text-decoration:none;
  background:transparent url(img/orange.gif) left bottom no-repeat;}
.navigation a:hover {background:transparent url(/images/green.gif) left bottom no-repeat;}


#header-image { background:#6b971b url(/images/header.jpg) top left no-repeat;width:900px; height:160px;}
#spacer { background: #ffffff url(/images/spacer.gif) top left repeat-x; height:9px;}

#main-navigation {
height:47px !important; height /**/:51px;
background:#edf4f7 url(/images/menu-bg.gif) top left repeat-x;
width:100%;
}

#main-navigation ul {
padding:0px;
margin:0px;
}

#main-navigation li {
float:left;display:block;
/*width:121px !important; width /**//*:122px;*/
width:127px;
text-align:center;
border-right: 1px solid #b5b6b7;
/*border: 1px solid #b5b6b7;*/
}

#main-navigation li.last{
border-right:1px transparent;
}

#main-navigation a {
  display:block;
  padding-top:12px;
  width:100%;
  height:35px !important; height /**/:51px;
  font-size:11px;
  font-weight:bold;
  color:#7f7f7f;
  text-decoration:none;
  background:transparent url(/images/orange.gif) left bottom no-repeat;
  }

#main-navigation a:hover {
background:transparent url(/images/green.gif) left bottom no-repeat;
}

</style>

<link rel="shortcut icon" href="favicon.ico" >

<style type="text/css">
<!--
.style1 {color: #FFFFFF}
-->
</style>

<table width="900"  border="0" align="center" cellpadding="0" cellspacing="0">
 
 <tr>

 
 <td width="900" height="147" valign="bottom" align="left" background="http://buyestablishedwebsites.com/images/header.gif">&nbsp;
       <!-- <div id="header-image"></div>
        <div id="spacer"></div> -->
</td>
   

  </tr>
 
<tr>
   
<td width="100%">
 <div id="main-navigation">
        <ul>
          <li><a href="/index.php">HOME</a></li>

          <li><a href="/buy_website.php">BUY WEBSITE</a></li>
          <li><a href="/sell_website.php">SELL WEBSITE</a></li>
          <li><a href="/myaccount.php">MY ACCOUNT</a></li>
          <li><a href="/support_center.php">SUPPORT CENTER</a></li>
          <li><a href="/website_flipping_blog/">BLOG</a></li>
          <li class="last"><a href="/forum">FORUM</a></li>

        <span class="clear"></span>
      </div>
<!-- <table  border="0" cellspacing="0" cellpadding="0">
<tr>

<td>
<a href="index.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image3','','images/home_over.jpg',1)" title="Home">
<img src="images/home.jpg" name="Image3" border="0" height="26" width="130" alt="Home"></a></td>

<td><a href="buy_website.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image4','','images/buy_over.jpg',1)" title="Buy Website">
<img src="images/buy.jpg" name="Image4" border="0" height="26" width="152" alt="Buy Website"></a></td>

<td><a href="sell_website.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image5','','images/sell_over.jpg',1)" title="Sell Website">
<img src="images/sell.jpg" name="Image5" border="0" height="26" width="150" alt="Sell Website"></a></td>

<td><a href="myaccount.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image7','','images/resources_over.jpg',1)" title="My Account">
<img src="images/resources.jpg" name="Image7" border="0" height="26" width="150" alt="My Account"></a></td>

<td><a href="support_center.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image6','','images/support_over.jpg',1)" title="Support Center">
<img src="images/support.jpg" name="Image6" border="0" height="26" width="169" alt="Support Center"></a></td>

<td><a href="forum" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image8','','images/forum_over.jpg',1)" title="Forum">
<img src="images/forum.jpg" name="Image8" border="0" height="26" width="149" alt="Forum"></a></td>


</tr>
</table> -->
    </td>
  </tr>
</table>
<div align="center"></div>

is being echoed BEFORE the doctype delcaration, breaking xhtml validation and the javascript.

I reccommend placing this code as appropriate in index.template.php

Wrapping this way is what is causing your problem
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

Quote
Microsoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"

Useful Links:
Online Manual!
How to Help us Help you   
Search
Settings Repair Tool