首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google日历布局

Google日历布局
EN

Stack Overflow用户
提问于 2013-11-28 23:06:28
回答 1查看 159关注 0票数 0

我一直在与此php代码,这应该会修改谷歌日历布局。但是当我把代码放到页面上时,下面的所有东西都会消失。它有什么问题?

代码语言:javascript
复制
<?php
$your_google_calendar=" PAGE ";
$url= parse_url($your_google_calendar);
$google_domain = $url['scheme'].'://'.$url['host'].dirname($url['path']).'/';

// Load and parse Google's raw calendar
$dom = new DOMDocument;
$dom->loadHTMLfile($your_google_calendar);

// Change Google's CSS file to use absolute URLs (assumes there's only one element)
$css = $dom->getElementByTagName('link')->item(0);
$css_href = $css->getAttributes('href');
$css->setAttributes('href', $google_domain . $css_href);

// Change Google's JS file to use absolute URLs
$scripts = $dom->getElementByTagName('script')->item(0);
foreach ($scripts as $script) {
$js_src = $script->getAttributes('src');
if ($js_src) { $script->setAttributes('src', $google_domain . $js_src); }
}

// Create a link to a new CSS file called custom_calendar.css
$element = $dom->createElement('link');
$element->setAttribute('type', 'text/css');
$element->setAttribute('rel', 'stylesheet');
$element->setAttribute('href', 'custom_calendar.css');

// Append this link at the end of the element
$head = $dom->getElementByTagName('head')->item(0);
$head->appendChild($element);

// Export the HTML
echo $dom->saveHTML();
?>
EN

回答 1

Stack Overflow用户

发布于 2013-11-29 01:35:37

当我测试你的代码时,我得到了一些错误,因为错误的方法调用:

->getElementByTagName应为->getElementsByTagName,元素上应为%s

->setAttributes->getAttributes应该是末尾没有%s的->setAttribute->getAttribute

我猜你没有打开任何error_reporting,因此不知道出了什么问题?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20269369

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档