小编Bil*_*ard的帖子

SEO - 在Onload之后通过JavaScript进行标题标记?

搜索引擎机器人是否在此页面加载后将javascript写入的元信息显示在页面的标题标签中?

我的代码执行以下操作

<body onload="myFunction(

         //find H1 on the page and put it into the title-tag in the header-section

)">
Run Code Online (Sandbox Code Playgroud)

为什么我这样做?因为它是一个具有不同内容的模板(相同的标题)(由URL-Parameters控制)

所以我可以填写修复元信息是(所有不同内容的相同元数据)...但我希望它像内容一样动态

有人可以给我一些提示或解决方案吗?

html javascript jquery dom

0
推荐指数
1
解决办法
292
查看次数

无法在perl中返回object属性的默认值

我有一个模块,当我试图在初始化中设置默认属性时,在调用子例程时给出以下错误 get_name

     Use of uninitialized value
Run Code Online (Sandbox Code Playgroud)

示例代码

     package test;
     #....
     #....
     sub new {
         my ($class) =  @_;
         my $self    = {};
         bless $self,$class;
         $self->_initialize();
         return $self;
     }

     sub _initailalize {
        my($self) = @_;
        $self = {
                     _name => 'NA'
        };
     }

     sub get_name {
              return $_[0]->{_name};
     }
Run Code Online (Sandbox Code Playgroud)

需要宝贵的投入.

oop perl

0
推荐指数
1
解决办法
89
查看次数

错误:mysql_fetch_assoc(表字段名称)

一切都很好,突然发生这种情况:

PHP警告:mysql_fetch_assoc()期望参数1是资源,布尔值在第17行的G:\ PleskVhosts\modelcharm.com\httpdocs\core\functions\users.php中给出

function user_data($user_id) {
    $data = array();
    $user_id = (int)$user_id;

    $func_num_args = func_num_args();
    $func_get_args = func_get_args();

    if ($func_num_args > 1) {
        unset($func_get_args[0]);   

        $fields = '`' . implode('`, `', $func_get_args) . '`';
        $data = mysql_fetch_assoc(mysql_query("SELECT $fields FROM `users` WHERE `user_id` = $user_id"));

        return $data;
    }}
Run Code Online (Sandbox Code Playgroud)

代码中有什么问题吗?

php mysql database login fetch

0
推荐指数
1
解决办法
298
查看次数

java卡在数组索引越界异常上

我对编程非常陌生,而且我一直卡在同一点上。每次我尝试使用数组时,我都会收到“线程“main”java.lang.ArrayIndexOutOfBoundsException 中的异常:”,我不知道如何修复它。这是我已经开始的:

public static void main(String[] args) {
Scanner input = new Scanner(System.in);

int i;
String format;
String[] value;
int[] number;

value = new String[10];
number = new int[10];
i = 0;

System.out.println("Please enter a phone number: ");
value[i] = input.nextLine();

for (i = 0; i < value.length; i++); {
    number[i] = Integer.parseInt(value[i]);
        System.out.print(number[i]);
Run Code Online (Sandbox Code Playgroud)

java arrays

0
推荐指数
1
解决办法
640
查看次数

如何在If Else语句中处理第二个条件

如何在If Else语句中处理第二个条件,我的if语句正在工作,但第二个条件不起作用(ElseIF),我的条件声明是否有问题?

Try
            If Val(TextBox7.Text.Trim.Split(".")(1)) >= 60 Then

                TextBox7.Text = Val(TextBox7.Text.Trim.Split(".")(0)) + 1 & "." & Val(TextBox7.Text.Trim.Split(".")(1) - 60) & " " & Format(Now, "MM/dd/yyyy")
                TextBox3.Text = Val(TextBox3.Text.Trim.Split(".")(0)) & "." & Val(TextBox3.Text.Trim.Split(".")(1) - 60) & " " & Format(Now, "MM/dd/yyyy")

            ElseIf Val(TextBox7.Text.Trim.Split(".")(1)) >= 100 Then

                TextBox7.Text = Val(TextBox7.Text.Trim.Split(".")(0)) - 1 & "." & Val(TextBox7.Text.Trim.Split(".")(1) - 45) & " " & Format(Now, "MM/dd/yyyy")
                TextBox3.Text = Val(TextBox3.Text.Trim.Split(".")(0)) - 1 & "." & Val(TextBox3.Text.Trim.Split(".")(1) - 45) & " " & Format(Now, "MM/dd/yyyy")


            Else …
Run Code Online (Sandbox Code Playgroud)

vb.net

0
推荐指数
1
解决办法
109
查看次数

全局符号"%self"需要Perl模块中的显式包名称

我正在编写一个Perl模块,并且在运行测试时遇到了这个令人困惑的错误消息.

sub new {
  my $class = shift;
  my $self = @_;
  $word = $self{word} || die "No word provided.";
  @definitions = @{decode_json(get($urban_url . $word))->{'list'}} || die "Error during fetch/decode.";
  @tags = @{decode_json(get($urban_url . $word))->{'tags'}} || "Error during fetch/decode.";
  bless($self, $class);
  return $self;
}
Run Code Online (Sandbox Code Playgroud)

如您所见,$self声明正确.word是在new子例程上面声明的全局变量.失败发生在use语句的每个测试中,并追溯到分配$word.

oop perl perl-module

0
推荐指数
1
解决办法
2378
查看次数

滚动时让Div"抓住"页面顶部

我在网页fixed 20px顶部有一个标题.

但是,我想在滚动时抓住页面的顶部,并在用户向下滚动20px后固定到屏幕顶部.

CSS

#header{
    padding: 0px 0px 0px 0px;
    background: url(../images/header-fill2.jpg) repeat-x top;
    position: fixed;
    height: 60px;
    width: 100%;
    top: 20px;
    z-index: 5000;
}
Run Code Online (Sandbox Code Playgroud)

我想有一些形式的JavaScript是必需的,但几乎没有JavaScript经验,所以任何帮助都将非常感激.

html javascript css jquery

0
推荐指数
1
解决办法
949
查看次数

为什么变量输出“None”

我试图帮助我的朋友做一个猜谜项目,但由于某种原因,guess 变量是 NoneType。你能帮我和我的朋友吗?

注意:出于技术原因,我已将 input() 替换为“hi”。

answer = "whatthing" #Change this to the answer
still_guessing = True
attempts = 1

guess = 'hi'
while still_guessing and attempts < 3:
  print(f'{guess}')
  if guess == answer.lower():
   print('Correct answer!')
   final_score = (3 - attempts)
   still_guessing = False
  else:
    guess = print('Sorry wrong answer. Try again.\n')
    print(f'Tries: {attempts}\n')
    print(f'You have {3 - attempts} left.\n')
    attempts += 1

  if attempts == 3:
    print('You coudn\'t find the answer in three tries, u suck!\n')
    print ('The correct …
Run Code Online (Sandbox Code Playgroud)

python variables python-3.x

0
推荐指数
1
解决办法
41
查看次数

为什么我可以在C++中为文字值分配现有引用?

考虑以下:

int ival = 1.01;
int &rval = 1.01; // error: non-const reference to a const value.
int &rval = ival;

rval = 1.01;
Run Code Online (Sandbox Code Playgroud)

&rval到文字值的第一次赋值失败了.如果我注释掉该行代码编译并运行.我理解为什么初始化失败了,但我很困惑为什么rval的赋值在最后一行工作.我认为不允许分配对文字值的引用.

编辑:谢谢你的快速解答.我很想删掉这个以掩饰我的耻辱,但我想我会留在这里,所以其他人都可以指出并笑.

在我自己的辩护中,我正在编写一本书中的练习(C++ Primer),这个问题与参考初始化有关.尽管如此,首先完全忽略了参考点是非常尴尬的.:)

c++ initialization reference literals variable-assignment

-1
推荐指数
2
解决办法
1936
查看次数

无需使用任何电源功能即可返回2的功率

我想要一个带有int xas参数并返回的程序2^x.实施不允许使用的权力.

public int double2 (int x) {
    int r = 2;
    int y = 1;
    for (int i=0; i < x; i++){    
        y = r* y;
    }
    return y;
}
Run Code Online (Sandbox Code Playgroud)

你认为这是一个正确的解决方案吗?

java

-1
推荐指数
1
解决办法
2190
查看次数