嗨我的问题是我无法加载一些
javascript文件@我的特殊页面扩展名.
我尝试使用addcript和其他一些方法,但唯一发生的事情是javascript被取消导致no-js的mediawiki软件.
我尝试使用addcript和其他一些方法,但唯一发生的事情是javascript被取消导致no-js的mediawiki软件.
在我的扩展名的文件夹中是一个new.js文件,我只想在我的特殊页面上访问它.
MyExentions.PHP
<?PHP if (!defined('MEDIAWIKI')) { echo <<<EOT To install my extension,put the following line in LocalSettings.PHP: require_once( "$IP/extensions/MyExtension/MyExtension.PHP" ); EOT; exit( 1 ); } $wgExtensionCredits['specialpage'][] = array( 'path' => __FILE__,'name' => '-','author' => 'Thomas Döring','descriptionmsg' => '-','version' => '0.0.1',); $dir = dirname(__FILE__) . '/'; $wgAutoloadClasses['SpecialMyExtension'] = $dir . 'SpecialMyExtension.PHP'; $wgExtensionMessagesFiles['MyExtension'] = $dir . 'MyExtension.i18n.PHP'; $wgExtensionMessagesFiles['MyExtensionAlias'] = $dir . 'MyExtension.alias.PHP'; $wgSpecialPages['MyExtension'] = 'SpecialMyExtension';
SpecialMyExtension.PHP
<?PHP class SpecialMyExtension extends SpecialPage { function __construct() { parent::__construct( 'MyExtension' ); } function execute( $par ) { $request = $this->getRequest(); $output = $this->getOutput(); $this->setHeaders(); # Get request data from,e.g. $param = $request->getText('param'); # Do stuff # ... if(file_exists("extensions/TimeLine/TimeLine/data.xml")) { $data = simplexml_load_file("extensions/TimeLine/TimeLine/data.xml"); foreach($data->event as $event) { $html.="<tr><td>".$event['title']."</td><td>".$event['start']."</td></tr>"; } $html.="</table>"; $html.="<a href=\"javascript:hello()\">klick</a>"; $output->addHTML($html); } else { $wikitext = 'Datei nicht gefunden!'; $output->addWikiText( $wikitext ); } } } ?>
我希望你能帮助我.
addScript适用于1.16及更早版本.在1.17及更高版本中,您应该使用addHeadItem:
原文链接:https://www.f2er.com/php/139152.html$wgHooks['ParserBeforeTidy'][] = 'wgAddJquery'; function wgAddJquery(&$parser,&$text) { global $addJqueryScripts; if ($addJqueryScripts === true) return true; $parser->mOutput->addHeadItem( '<script language="JavaScript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>' ); $addJqueryScripts = true; return true; }