SimplePortal

Customization => Custom Coding => Topic started by: phantomm on February 28, 2013, 10:18:03 AM

Title: Changing forum title if there is new shout
Post by: phantomm on February 28, 2013, 10:18:03 AM
Hi, so I've been trying to make something like this:

If there is new shout in SP Shoutbox forum title would be changed to "New shout!", but when you visit tab/window with this shourbox it should be changed to default forum title.

I know how and where* use document.title = 'New shout!';. Problem is how to reset forum title to default after visiting page, without need to refresh whole page?

* - you need to add document.title before this code in portal.js
Code: [Select]
}

setInnerHTML(document.getElementById('shouts_' + shoutbox_id), new_body);
Title: Re: Changing forum title if there is new shout
Post by: Chen Zhen on February 28, 2013, 11:32:27 AM
phantomm,

  Imo use DOM or javascript.

Here it is using javascript:
Code: [Select]
echo '<script type="text/javascript">
    document.title = "New Page Title";
  </script>';

Title: Re: Changing forum title if there is new shout
Post by: phantomm on February 28, 2013, 01:01:50 PM
Thanks for repy, but this code will change title right after page will be loaded.
What I need to have here is JS to set specified forum title when user will go to already open tab.
Title: Re: Changing forum title if there is new shout
Post by: Chen Zhen on March 04, 2013, 02:49:42 AM
Thanks for repy, but this code will change title right after page will be loaded.
What I need to have here is JS to set specified forum title when user will go to already open tab.

phantomm,

  My apologies for the late reply as I am working on a project as of late.
I have not tested it but you put what I posted in a js function & have it execute the function when the shout button or ie. onkeydown keycode 13 (return/enter) is executed if I understand you correctly.

Code: [Select]
echo '<script type="text/javascript">
onLoad = function changeTitle() {
    document.title = "New Page Title";
}
  </script>';
.. then in the js for what I mentioned prior you execute changeTitle()
SimplePortal 2.3.8 © 2008-2024, SimplePortal